Skip to main content

How to calculate percentages in a formula variable

Dynamically calculate percentages using formula variables for grading quizzes, analyzing survey results, calculating ROI, and more!

Updated today

You can use formula-type variables to dynamically calculate percentages inside your form. This is useful for grading quizzes, analyzing survey results, calculating metrics like ROI, or applying discounts to the final price.

💡 Learn more about formula variables, their use cases, and setup nuances in this article on how to use a variable with a formula

💡 Learn more about all variable types and general use cases in this article on what variables are, why & how to use them

When do you need percentage calculations?

You’ll often want to calculate percentages in use cases like:

  • Calculating metrics like ROI (e.g., result / investment × 100)

  • Showing how much of a total score was achieved on a quiz

  • Estimating discounts or price reductions

Let’s go through three examples that show different ways to calculate percentages in forms.

How to set up the formula for your variable

To add a formula-type variable:

  • Go to the Variables tab in your form editor and add a new variable with type set to Formula.

  • In the Default Formula field, use math operations (+, −, *, /), numbers, or pull values from other fields or variables by referencing their IDs (e.g. total_price * 0.75).

☝️ Parentheses are not supported in the formula variables. When setting up formulas, avoid using parentheses. For complex calculations, follow a step-by-step approach by creating separate variables for each part of the calculation.

Example 1: ROI calculator

Let’s say you want to calculate return on investment based on two values submitted in your form.

Step 1: Create number fields for input

  • Add two number fields with IDs: return and investment.

Step 2: Add a formula variable to calculate ROI

  • Add a formula variable with ID roi, and add return / investment * 100 in the Default formula field.

Step 3: Show the result using answer piping

  • Display the calculated ROI in a content block or on the ending page using answer piping:

Example 2: Personality quiz with percentage scores by trait

Let’s say your personality quiz gives a separate score for each trait, and you want to calculate what percentage of the total each trait represents — for example, “70% dominant and 30% conscientious.”

Step 1: Build a personality quiz with trait-based scoring

  • Create a quiz with four integer or decimal variables: dominance, influence, steadiness, and conscientiousness. Use logic rules to add points to these variables based on respondents’ answers.

Step 2: Add a variable for total score

Since formulas don’t support parentheses, you need to break calculations into separate steps, first calculating the total score as the sum of scores, like this:

  • Add a formula variable with ID total_score, and use this formula:
    dominance + influence + steadiness + conscientiousness

Step 3: Create percentage variables for each trait

To be able to calculate the % of each trait from the total:

  • Create four new formula-type variables – for example, for an integer variable for dominance, create an additional formula variable with ID dominance_percent.

  • In each formula, divide the trait's score by the total score and multiply by 100 to get a % value:

dominance_percentdominance / total_score * 100

influence_percentinfluence / total_score * 100

steadiness_percentsteadiness / total_score * 100

conscientiousness_percentconscientiousness / total_score * 100

Step 4: Show the result using answer piping

  • Display the final results using content blocks or ending page messages with answer piping. For example:

You're @dominance_percent% dominant – bold, driven, and quick to take charge,
You're @influence_percent% influential – expressive, outgoing, and energised by people and ideas,

Etc.

Example 3: Total price with a discount

Let’s say you want to apply a discount to the final price in your form.

Step 1: Use a formula variable to apply the discount

  • In your form, where you already have a field or variable that holds the total price value (e.g., price_estimate), create an additional formula-type variable to apply the discount.

  • Since subtracting percentages directly isn’t supported, you’ll want to multiply instead:

For a 10% discount, use price_estimate * 0.9

For a 25% discount, use price_estimate * 0.75

Step 2: Show the discounted price using answer piping

  • In a content block or on the ending page, use answer piping to display the discounted price to the respondent. For example: “Enjoy 10% off for your first order! Discounted price: $@discounted.

You can now build smarter, dynamic forms that calculate percentages in real time — whether for scoring, pricing, or logic-based workflows.

Did this answer your question?