Answered

Calculating savings from client results


Userlevel 1
Badge

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:

(A) BAMS Volume

(B) BAMS Fees

(C) PreBAMS AMEX Volume

(D) PreBAMS AMEX Fees

(E) PreBAMS V/MC/D Volume

(F) PreBAMS V/MC/D Fees

 

The calculation I’m trying to do is:

(((D + F) / (C + E)) - (B / A))*(C + E) = Calculation I’m looking for

 

This can be broken down into pieces if easier / better supported by the Typeform capabilities. 

icon

Best answer by john.desborough 16 July 2022, 04:20

View original

10 replies

Userlevel 7
Badge +6

@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 .. 

 

des

Userlevel 1
Badge

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?

Userlevel 1
Badge

@john.desborough sorry through some Googling I figured that part out :)

 

I think I was able to make it all work so I’ve implemented your outline and will test it shortly!

 

Thank you for all your help!

Userlevel 7
Badge +6

@BAMS - glad to hear.. hope it works

 

Userlevel 1
Badge

@john.desborough Thanks so much for your help. 

 

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?

Userlevel 7
Badge +6

you should be able to use the @recall function on the page.. the value of the ‘w’ variable is the result

 

so do something like this on a statement page after the calculation

 

Here’s the answer: @w 

 

and that should show the value.. 

 

Userlevel 1
Badge

Thank you for that!  I tested it and the calculation I’m getting is way off.  

Can you review my setup below and see if you can tell where the mistake is?

Here is the link to the typeform itself if thats helpful: 

 

Userlevel 7
Badge +6

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. 

 

des

Userlevel 1
Badge

@john.desborough I cleared out everything, put it all at the end and then did it step by step to check the math and it worked!!

Thank you so much for all your help!!

Your knowledge is incredible and assistance was invaluable. 

Thank you!!

Userlevel 7
Badge +6

Glad to hear that it worked @BAMS 

(now Duplicate the quiz so that you have a backup lol!!) 

 

cheers

 

des

Reply