To perform calculations using formulas, you need to use Variables
Example 1: Tax calculations
In this example, we need calculate:
Subtotal - Based on what products/services have been selected/number entered.
Tax - Tax amount (20% of subtotal)
Final total - Subtotal + Tax
Step 1 - Setting up Variables - @Subtotal, @Tax and @Finaltotal
Step 2 - Performing calculations using variables
2a. Use a Subtotal variable to collect the values of what items have been selected/number entered.
2b. Add the final subtotal to the Tax variable
2c Multiply the tax variable by 0.20 to calculate the tax (e.g. 20% tax)
2d. Add the subtotal and tax to Finaltotal
Step 3 - Use Recall (@) on page to show Subtotal, Tax and Finaltotal
Step 1 - Setting up Variables - @Subtotal, @Tax and @Finaltotal
Step 2 - Performing calculations using variables
Step 3 - Use Recall (@) on page to show Subtotal, Tax and Finaltotal
Below, you can try out the above form we built:
Tax calculations - https://getformly.app/JXSoKq
Tip! - You can also import above template in your account to check the calculations and how to setup variables.
Example 2: Wall paper - Quantity and Cost calculator
In this example, we need calculate:
Number of rolls needed - Based on Area to cover (Width * Height)
Total price ($) - Number of rolls needed * 20
Assumptions:
- one wall paper roll covers 5 m²
- one wall paper roll costs - $20
Step 1 - Setting up Variables - @Width, @Height, @subtotal_area, @Final_area, @Number_of_rolls_needed, @Total_price
Step 2 - Performing calculations using variables
2a. Use a Width and Height variable to calculate Final area to cover: (Width * Height) m²
2b. Number of rolls needed: Area to cover/5
2c Total price ($): Number of rolls needed * 20
Step 3 - Use Recall (@) on page to show Final Area to cover, Number of rolls needed and Total price
Step 1 - Setting up Variables - @Width, @Height, @subtotal_area, @Final_area, @Number_of_rolls_needed, @Total_price
Step 2 - Performing calculations using variables
Step 3 - Use Recall (@) on page to show Total area to cover, Number of rolls needed and Total price.
Below, you can try out the above form we built:
Wall paper: Quantity and Cost calculator - https://getformly.app/gProD2
Tip! - You can also import above template in your account to check the calculations and how to setup variables.
Example 3: Show values as percentages
The quiz tests knowledge of 3 topics - Science, Math and Geography.
Scoring:
Each topic (Science, Math, and Geography) has 3 questions.
Total score for each topic is out of 3.
Maximum overall score: 9 points.
For each correct answer: +1 point
Step 1 - Setting up Variables - @Science, @Math, @Geography, @Total_score
Step 2 - Performing calculations using variables
2a. Use a topic variable to collect the values for respective topic questions. The value of the variable increases by 1 point only when a respondent answers a question correctly in that topic.
For each correct answer: +1 point
2b. Always add individual topic score to Total score.
2c. This below rule will convert your variable’s value at the end of the quiz into a percentage-friendly format.
Add a rule so that the variable’s value is always divided by the total number of questions.
Also, Add a rule so that the variable’s value is always multiplied by 100.
Always Divide @Science by 3
Always Mulitply @Science by 100
Always Divide @Math by 3
Always Mulitply @Math by 100
Always Divide @Geography by 3
Always Multiply @Geography by 100
Always Divide @Total_score by 9
Always Multiply @Total_score by 100
Step 3 - Use Recall (@) on page to show individual topic score (Science, Math and Geography) and Total score in percentage format.
Step 1 - Setting up Variables - @Science, @Math, @Geography, @Total_score
Step 2 - Performing calculations using variables
Step 3 - Use Recall (@) on page to show individual topic score (Science, Math and Geography) and Total score in percentage format.
Type “%” to the right of the variable, to make it clear to the respondent that you’re showing them a percentage score.
Below, you can try out the above form we built:
Knowledge quiz: Show values as percentages - https://getformly.app/scsqTj
Tip! - You can also import above template in your account to check the calculations and how to setup variables.
Example 4: Field value formula
In this example, we need to calculate final value for the below formula:
Formula: ((Field A x 1.49) - (Field B x 20%) + (Field C x 0.5))
Step 1 - Setting up Variables - @A_calculations, @B_calculations, @C_calculations and @Final_total
Step 2 - Performing calculations using variables
2a. Use @A_calculations variable to collect the value of number entered in Field A and then multiply it by 1.49
2b. Use @B_calculations variable to collect the value of number entered in Field B and then multiply by 0.2 (20%)
2c. Use @C_calculations variable to collect the value of number entered in Field C and then multiply by 0.5
2d. Add @A_calculations to @Final_total
2e. Subtract @B_calculations from @Final_total
2f. Add @C_calculations to @Final_total
Step 3 - Use Recall (@) on page to show A_calculations, B_calculations, C_calculations and Final_total
Step 1 - Setting up Variables - @A_calculations, @B_calculations, @C_calculations and @Final_total
Step 2 - Performing calculations using variables
Step 3 - Use Recall (@) on page to show A_calculations, B_calculations, C_calculations and Final_total.
Below, you can try out the above form we built:
Field value formula - https://getformly.app/e86u4B
Tip! - You can also import above template in your account to check the calculations and how to setup variables.