Skip to main content
Question

Variable calculation #2

  • February 12, 2026
  • 2 replies
  • 10 views

johnt
Forum|alt.badge.img+1

This is a development/continuation of a question I asked some months ago. Previously, I asked about comparing variables, and with valuable help from ​@john.desborough I resolved it. “I created another variable (balance) that takes its value from the figure for income. Then I added the figure for expenses to the surplus variable, subtracted the surplus value from the balance and compared income to balance. This allows the comparison to be made leaving the income figure intact.”

That calculation was to determine whether income is greater (by a factor) than expenses. Now I’d like to add another calculation that determines whether expenses are more than income. I have tried to follow the same pattern creating another variable, ‘deficit’,

  • Add expenses to deficit
  • Subtract income from deficit
  • Query whether deficit > 0

However, putting both calculations in the same questions ends in a mess. I can’t work out how to put two calculations, with two outcomes into the same question. When I put test figures into the questionnaire, the first calculation works ok, but it always proceeds to the second. Both statements can’t be true - either income is greater than expenses, or expenses are more than income.

I’d be very grateful for suggestions or a solution.
 

2 replies

Grace
Community Team
Forum|alt.badge.img+5
  • Community Advocate
  • February 13, 2026

Hi ​@johnt happy Friday! I’m so sorry, for some reason the spam filter picked up your post and we missed it! 

@john.desborough do you think you might be able to help a fellow John again? 


john.desborough
Forum|alt.badge.img+6
  • Certified Partner & Champion
  • February 13, 2026

@Grace ​@johnt - use a a variable for the running total. 

here’s what i did in this sample

 

created variable v_running to hold the running total:

add q1 to v_running

add q2 to v_running

subtract q3 from v_running

then

 

are your (expenses + deficit) greater than your income?

ie (expenses + deficit) - income GT zero, the answer should be NO

if (expenses + deficit) - income LT zero, the answer should be YES

 

evaluate v_running LT or GT 0 and set value of v_yesno

 

you should see this same detail in the typeform. 

 

des