Skip to main content
All CollectionsBuild & customizeForm logic & calculations
How to calculate scores using Variable fields
How to calculate scores using Variable fields

Calculate scores, totals, and recommendations based on user input. Use variables, logic, and answer piping to personalize results.

Updated over 2 weeks ago

Variable fields allow you to calculate and display scores, totals, or other custom outputs based on user input.

They are highly versatile and can be used for various purposes, such as score calculations in quizzes, estimations for pricing, and more.

This tutorial will guide you step-by-step on how to set up variable fields for calculating scores in your forms.

Step 1: Create a form with a variable field

  1. Navigate to the dashboard:

    • Click on + New Formaloo and select either a form or a survey for your project.

  2. Add question fields:

    • A combination of text fields (for basic info like the name), single-choice fields (for quiz questions), and variable fields (for score calculation).

  3. Add an ID for the variable field:

  • Assign a unique ID to each variable field. This ID is essential because it allows you to reference the variable in formulas and success messages, enabling you to display calculated scores or other values dynamically (e.g., showing the total score to the user after submission).

For this tutorial, we will be creating a self-grading quiz, therefore, we will need the following fields:

  • Short/long text fields - to gather basic information, like the student's name;

  • Single-choice fields - to add quiz questions;

  • Content fields - for section introductions, like Geography, History, Science and Math;

  • Variable fields with ID - for calculating the score.

Step 2: Add scores to each question

  1. Open the form editor:

    • Select the question you want to score, then click on the Logic tab on the right sidebar.

  2. Set a score for correct answers:

    • In the Advanced Logic section, click on + Add Condition and set the logic for each correct answer separately for each question. When a condition is set on a field, it will be checked when that specific field is being answered.

    • For example, if the answer is Option 1, assign a score of 5 to that option.

  3. Repeat for all quiz questions:

    • For each quiz question, repeat the process of assigning a score to the correct answer.

Add score in logic

Create Variable Fields for Multiple Scores

Step 3: Add Variable fields to calculate the total score

If you want to calculate more than one score type on your form (e.g., Math, Science), add a separate variable field for each score category.

Assign each field a unique ID, such as math_score or science_score.

  1. Create variable fields for multiple scores:

    • For different categories (e.g., Science, Math), create variable fields that store the scores.
      Assign an ID to each field (e.g., science_score, math_score).

    variable

  2. Set up the formula for the total score:

    • Create a Variable field to calculate the total score.

    • Select the type of variable field as Formula, and in the Default value section, use the sum of all score variables (e.g., science_score + math_score + history_score).

    • Assign an ID to the total score field (e.g., total_score).

Step 4: Display the total score on the success page

  1. Customize the success message:

    • After the user submits the form, you can display the total score on the success page.

    • Use answer piping to show the score dynamically by adding the ID in the success message:

      • Your Total Score is {{total_score}} or @total_score

    Ending page with answer piping


    2. Add multiple success pages (optional):

    • If desired, create additional success pages and display different results based on the total score.

multiple success page


Additional use cases for Variable fields

  • Estimation forms: Use variable fields to estimate project costs or pricing structures.

  • Product recommendation forms: Customize pricing or recommendations based on selections.

Variable fields can enhance user interaction by providing personalized results, making your forms more dynamic and tailored to the user’s input.

🗄️ Old dashboard:

You can see all the variables and IDs in this template: Online quiz

number field
real time
Did this answer your question?