Answered

How to turn variable number into proper formatting at the end of a calculation (instead of ending up with 7 zeros)

  • 11 September 2022
  • 12 replies
  • 156 views

Userlevel 1
Badge

Hi. I’m trying to have a basic “savings calculator” done in Typeform. My end result should be $1,250, but instead it comes back as one large number: 12500000000.

Right now, they enter a house appraisal amount, then they enter the amount they think it should be, then they enter their property tax rate percentage (needs to handle decimals), then I want to show them the final result.

Here are the form steps:

Step 1: Enter the appraisal amount (i.e. 500000)

Step 2: Enter the amount you think it should be (i.e. 450000)

Step 3: Enter your property tax rate (i.e. 2.5) should be a percentage

Step 4: The result should be 50000 x 2.5% = 1250

There has to be a way to format these numbers correctly. It’s basic calculator stuff.

orrectly, right? I’ve seen some older posts in the community where probably 100 people are requesting basic calculation results that can show properly formatted numbers.

Is there a way to do this?

icon

Best answer by john.desborough 12 September 2022, 18:03

View original

12 replies

Userlevel 7
Badge +6

@joshhayles - understand your pain. simplest way to get to the percentage bit you want is to add one step in the logic: after they enter the tax rate ie 2.5, you can multiply by the 2.5 and then divide the result by 100. that will give you the reduced number that you want

Userlevel 1
Badge

Hi, John. This is definitely difficult.

I’m attaching screenshots to show what I have. 

I think I need to “add question number 4 into a variable”, which would preferrably be my tax_rate variable. Then divide that by 100, but the drop downs won’t let me choose question number 4. I think it’s because I have it set as a text question instead of a number question. 

However, I had to change it to text because the number field doesn’t accept decimals.

My current setup gives me the correct subtraction (Appraisal district minus the 

So … I’m stuck.

Any thoughts?

 

 

Userlevel 7
Badge +6

@joshhayles - you could add some logic behind number 4 along these lines: based on the selection from your drop down

  • if q4 = A (ie 2.5%) then add 25 to variableX 
  • if q4 = B (ie 3.0) then add 30 to variableX
  • if variableX is gt 0 then divide variableX by 1000

that should give the two decimal points of accuracy (typeform does not go three places unfortunately)

just a thought before i go cut the grass

 

des

 

Userlevel 1
Badge

I’m still not able to get it working. 

If the user enters $300000 for the Appraisal District amount …

then enters $250000 for the Homeowner Price …

I want to subtract the Appraisal District amount from the Homeowner Price, which in this case is a difference of $50000.

Then, I want to multiply that 50000 by the tax rate the user enters. 

So, if they enter 2 for the tax rate (representing 2%), 50000 x 2% = $1000

Then I want to display that $1000 to the user at the end.

Here are my most recent screenshots …

 

 

 

Userlevel 7
Badge +6

@joshhayles - test this one please to see if it gives you the anticipated results

Userlevel 1
Badge

YES!! How did you do that? LOL.

Userlevel 7
Badge +6

 

Userlevel 7
Badge +6

@joshhayles - one thing i did not put in here is a branch to see if the homeowner value was greater than the appraised value - that would result in a negative value in the ‘difference’ and would probably need a statement that said “ you put in a value higher than the @recall value of appraisal .. go back and change it” … or something like that

Userlevel 1
Badge

Thank you so much! I can’t tell you how appreciative I am!

Lastly, is there a way to use two decimal points at the very end, so the result would look like $1000.00 ?

Userlevel 7
Badge +6

@joshhayles if all the answers will show up as whole $$ then you could use this type of approach: 

 $@recall_field.00

on the question in the builder, you would type the $ as a hardcoded element, then insert the recalled variable and then hardcode the “.00” at the end of the variable pasted onto the question. 

if it going to ever have a decimal value in the calculation, then you would not use the .00 approach. 

des

Userlevel 1
Badge

That works! Thanks again for your help!!

Userlevel 7
Badge +6

@joshhayles - you’re welcome.. pay it forward and buy an ‘old timer’ a coffee next time you are out.. 

 

cheers

 

des

Reply