Variable calculation | Community
Skip to main content
Answered

Variable calculation


johnt
Forum|alt.badge.img+1
  • Socializer
  • 13 replies

I want to determine whether variable a is greater than variable b by a set margin (a number that I can change). Both of these variables are scores derived from a series of answers. For example, “is variable a > (variable b + 300)”.

I can’t see a way to compare variables. Grateful for any advice.

Best answer by john.desborough

@johnt  - not directly.. 

  • create variable v_b_plus_constant (as an example) and set the default value to your constant ie 3000
  • logic rules
    • add variable_b to v_b_plus_constant
    • subtract v_b_plus_constant from variable_a
    • if variable_a is greater than 0 then go to the ‘yes’ answer question/ending …

it’s not perfect but it works

des

View original

5 replies

john.desborough
Forum|alt.badge.img+6
  • Certified Partner & Champion
  • 5351 replies
  • Answer
  • May 27, 2025

@johnt  - not directly.. 

  • create variable v_b_plus_constant (as an example) and set the default value to your constant ie 3000
  • logic rules
    • add variable_b to v_b_plus_constant
    • subtract v_b_plus_constant from variable_a
    • if variable_a is greater than 0 then go to the ‘yes’ answer question/ending …

it’s not perfect but it works

des


johnt
Forum|alt.badge.img+1
  • Author
  • Socializer
  • 13 replies
  • May 28, 2025

Thanks John, that works.

I got as far as thinking that I need to create a third variable to represent the ‘surplus’ but couldn’t see how to take that further.

Thanks for your help.

John


johnt
Forum|alt.badge.img+1
  • Author
  • Socializer
  • 13 replies
  • June 26, 2025

Hi John

I incorporated your suggestion into my form and it appeared to be working OK when I tested it. However, now it’s out in the real world, it seems it’s not working as expected.

In this form, variable a is income and variable b is expenses, both of which are reported in the results we get from an applicant. So my version of your solution is:

  • Set the surplus variable (your v_b_plus_constant) to 300.
  • Add expenses to surplus.
  • Subtract surplus from income.

However, subtracting the surplus (which is expenses + 300) from income, the form then reports, in some instances, that income is a negative figure.

So I’m stuck again. I’d be grateful for your ideas.

Thanks

John


johnt
Forum|alt.badge.img+1
  • Author
  • Socializer
  • 13 replies
  • June 27, 2025

I’ve resolved it. And it’s blindingly obvious really, just needed to come back to it a bit later.

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.

John


Grace
Community Team
Forum|alt.badge.img+5
  • Community Advocate
  • 2821 replies
  • June 30, 2025

Hey ​@johnt just wanted to pop into this conversation and say, great to hear you managed tor resolve it, we always appreciate it when people pop back in and tell us what they’ve done - you never know when there’s another Typeform user out there looking for the same thing so I’m sure this will be helpful! 

And thanks to ​@john.desborough for getting you on the right track! 

Have a good week 😊


Reply