Variables are placeholders for hidden, calculated values or data.

They allow you to store and process information within your form, which can be used dynamically with other form components, such as calculated value controls and logic-based rules.

You can use logic in combination with variables to assign different values or outcomes based on user input.

## What are variables

Variables in a form act as placeholders for data that are calculated or hidden behind the scenes. For example:

**Scores**: In a quiz, variables store the score based on correct or incorrect answers.**Amounts**: In a donation form, a variable might hold the payable amount.**User inputs**: Variables can store data like BMI results, product recommendations, or personalized responses.

## Uses of variables:

**Score calculation**: In quizzes, variables can store individual or total scores, which are calculated based on user answers.**Estimations**: In price calculators or estimators, variables are used to calculate totals based on user inputs like quantity, size, or options.**Data transfer**: Variables can be used to transfer data between different form fields using logic and answer piping.

## How to use variables in logic

### Assigning values to variables using logic:

Logic can be used to change or assign values to a variable based on conditions that occur as a user fills out the form.

For instance, if a user selects a specific product or option, you can set up logic to update a variable with the corresponding value.

**Example 1: Product recommender quiz**

In a product recommender quiz, you may have multiple products, each with weighted factors assigned based on user preferences.

You can use variables to store these weights. As the user selects options, logic will sum the weights, and the total score will be stored in a variable, determining which product is recommended.

#### Example 2: Personality quiz using variables and logic

For a personality quiz, variables can store scores for different personality types based on user responses.

As the user answers questions, logic can add to the score for each type.

At the end of the quiz, the variable with the highest score will determine the user’s personality type, and logic will show the result accordingly.

#### Example 3: BMI calculator using variables and logic

Let’s consider a BMI calculator as an example of how to use variables:

**Step 1**: The user enters their weight and height.**Step 2**: Logic calculates the BMI by applying a formula to these inputs using variable fields.**Step 3**: The variable holds the calculated BMI score.**Step 4**: Based on the BMI result, logic connects to different success messages, showing whether the user is underweight, normal, overweight, or obese.

## Visualizing variable interactions with a Logic Map

Using variables alongside conditional logic introduces multiple dynamic pathways in your form, and a **logic map** is an essential tool to keep track of these interactions.

With a logic map, you can see how variables are assigned, computed, and utilized throughout the form, offering a clear view of each step in the process.

## How the Logic Map enhances variable-based forms

**Simplify complex calculations**: For forms that use variables, like score calculations or product recommendations, the logic map shows how each variable is calculated and where each condition branches out.**Check for consistency**: Review connections to ensure that variable calculations and conditions lead to the correct outcomes without conflicts.**Refine the user path**: By seeing how each input affects variable-driven outcomes, you can create a seamless, personalized experience that adapts as users complete the form.

## Accessing the Logic Map for variables and conditions

**Go to the Logic Tab**: Open the form editor and navigate to the Logic tab where variables and conditions are set up.**Select the Logic Map Overview option**: Within the Logic tab, click on Logic Map to see a visual layout that represents your form’s structure and how variables interact with other fields.**Review variable pathways**: In the map, check how each user input and assigned variable connects, ensuring that the calculated values display as intended.

With the **logic map**, you can handle even complex variable scenarios with ease, refining the form's interactivity and ensuring a cohesive flow from start to finish.

**📝 Additional insights:**

**Answer Piping**: You can use answer piping to transfer the value of one variable field to another field within the form or success page. For example, the calculated BMI score can be displayed in a success message by referencing the variable ID.