 # Calculate formula

I am trying to calculate a formula based on the selection in a dropdown. In the blend percentages dropdown, the user can select anything from 100% to 25-25-25-25% blend percentage. According to which blend percentage the user selects, it changes how I need to calculate the formula. Each blend percentage has a certain variable that I need to times by either .50, .33, .25 etc.

I am trying to figure out a way to have a hidden input box that takes the blend percentage selected by the user, and input a certain value based on their selection. For example, if the user selects “75%-25%”, the input field will show .75. I will then use that input field to run my calculation off of.

Any suggestions would be greatly appreciated!

Thanks,
Scott

Hey Scott,

You’re on the right track. Have an input element with “this element is visible on page load” unchecked. And use conditions to set different initial content values based on the dropdown selection.

For example: when dropdown’s value is “50%-50%” > initial content = .50

Just remember that the dropdown value in the conditions need to be written exactly as you have written it in the dropdown element (case-sensitive). So create a different condition for each dropdown value.

If you want to consolidate this a little and/or if these blend percentages are saved to your database under a Blend Percentage type, you could also just add another field to store the multiplier value. Then you wouldn’t need conditions. Just set the default initial content to “Dropdown value’s multiplier”

Hope this helps!

Gaby | Coaching Bubble

@romanmg
That’s perfect!! Thank you. I was able to get the formula to calculate correctly using states as well.

Do you know how I can round a number? I see the :round to option, but not sure what to put after it. The number I am currently getting from my formula is quite long, more than 10 decimal points. I want it to be a whole number.

Thanks!!

1 Like

The number you put after the :rounded function is the number of places after the decimal you want included.

If you want a whole number put “0”, indicating no places after the decimal

Geoff | Wolfer Tech
Check out
The Best Selling Bubble Template
The Most Used Bubble Template (FREE)

1 Like

@gf_wolfer exactly what I wanted! Thank you. I’ll give it a shot.

Gaby, could you elaborate on how to actually set initial values to drop downs? I am stuck here:

I could set the value (in fact answer of current user) for other input fields but not for this one.