I was not able to find anything addressing this specifically but I was trying to build a form to calculate the savings new clients have realized by working with my company.
These are the fields and for the sake of ease I will assign each a letter to demonstrate the calculation:
This can be broken down into pieces if easier / better supported by the Typeform capabilities.
Best answer by john.desborough
@BAMS - if these are answers to questions that you have created you need to put in place a series logic rules to do the calculations.. in the logic samples that i use below, i have created a series of variables to act as additional ‘holding places’ for some of the calculations - the logic rules are a cumbersome beast and don’t allow you to do this calculation in one fell swoop
place holder variables are defined here as w, x, y and z
if d is greater than or equal to 0 then add d to w
if f is greater than or equal to 0 then add f to w
if c is greater than or equal to 0 then add c to x
if e is greater than or equal to 0 then add e to x
if b is greater than or equal to 0 then add b to y
if a is greater than or equal to 0 then divide y by a
these rules would reduce the equation above to
(w/x -y) * x
now the rest of the calculations in the logic rules
if w gte 0 then divide w by x
if y gte 0 then subtract y from w
if x gte 0 then multiple w by x
that should give you the answer.. convoluted logic but ..
@BAMS - if these are answers to questions that you have created you need to put in place a series logic rules to do the calculations.. in the logic samples that i use below, i have created a series of variables to act as additional ‘holding places’ for some of the calculations - the logic rules are a cumbersome beast and don’t allow you to do this calculation in one fell swoop
place holder variables are defined here as w, x, y and z
if d is greater than or equal to 0 then add d to w
if f is greater than or equal to 0 then add f to w
if c is greater than or equal to 0 then add c to x
if e is greater than or equal to 0 then add e to x
if b is greater than or equal to 0 then add b to y
if a is greater than or equal to 0 then divide y by a
these rules would reduce the equation above to
(w/x -y) * x
now the rest of the calculations in the logic rules
if w gte 0 then divide w by x
if y gte 0 then subtract y from w
if x gte 0 then multiple w by x
that should give you the answer.. convoluted logic but ..
Hi @john.desborough thank you for your detailed, quick and helpful answer!!
I tried implementing and the one sticking point I’m having is how to create the place holder variables w, x, y and z. When I’m in the calculation window I currently only have one variable available to me called “@score” which can operate as X, see below:
Is there somewhere else I need to pre-generate the additional variables who will operate as W, Y, and Z to be able to organize the entire series of calculations?
I think I have one last question (and sorry if its a dumb) one but how do I get the result of the calculation?
I’ve figured out the basis processes of setting up the variables and the formula but I can’t figure out how / where the result of the calculation is produced to?
your best bet, to assist in the troubleshooting, is to:
put all the logic rules i mentioned AFTER all your inputs have been gathered ie on the last question
insert a statement page and use the @recall function to display the answers to the questions, the values in the individual variables and the outcome of each of the steps in the calculation
this way you can see each of the calculations
try that out first to see if you can spot your errors - what i notice in your images above is that on q3 you are dividing a variable that an answer - have you defined a value for that variable by default? if not there will be an error.