Signup
 

How to add and change variables

You can use variables within Branching & calculations to add up scores or prices. You can also create your own custom variables in Number or Text format. 

Add variables

1. Go to the Logic tab on the right-hand side of the Create panel, open Personalize with data, then select Variables.

2024-07-16_13-40-57.png

2. Now you’ll see the default variables. Click + Add custom variable to create your own. Choose Number or Text from the drop-down menu, and optionally add a base value. Hit Save when ready.

Note! Only lowercase letters, numbers, and underscores are accepted when creating a custom variable. 

2023-07-28_12-44-20.png

 

HC_BobRoss_ilu_cropped.png
Tip! Adding a base value can be useful for defining a unit price or a default text string that you’d like to display in your form later.

You’ll always see the price and score Variables in the list, but they're grayed out by default. The price Variable will become available when you add a Payment question to your form, and the score Variable will become available when you add scores.

You can show a variable’s current value in your form questions by typing @ and using Recall information.

2024-04-04_13-49-21.png

Changing the value of Number variables

You can change the value of Number variables by adding rules in the Branching, segmentation and calculations menu, in the Logic tab.

2024-07-16_13-40-57.png

1. Open the branching menu and click + Add rule by the question you want to edit. 

2024-07-16_13-46-30.png

2. Switch from “if” to “always” in the first dropdown menu to always change the variable’s value when that question is answered.

In the next dropdown menu, choose a math operation to apply to the variable, the variable you’d like to change, and the factor you’d like to change it by. This factor could be another variable, the question answer, or a number you choose.

2024-07-16_13-55-46.png

For example, you might create a rule like this for a question like “How many pizzas would you like to order?” You can then multiply an order price variable by the respondent’s answer:

2024-07-16_13-58-11.png

3. To only change the variable’s value in certain cases, choose “if” in the first dropdown menu. Add the appropriate condition before setting up the rest of the rule.

2024-07-16_14-00-09.png

For example, you can create a rule like this for the question “What pizza size would you like?” The order total variable would increase by different amounts depending on the chosen size.

2024-07-16_14-00-55.png

4. You can use Number variables to change the value of other Number variables. For example, if you had a Number variable called blue and another Number variable called red, you could add, subtract, multiply, or divide between the two:

2024-07-16_14-03-29.png

How do these operations affect each variable? Let's say that you start with two variables, red, with a value of 10, and blue, with a value of 5.

  • If you add blue to red, the value of red becomes 15, and the value of blue stays at 5.
  • If you add red to blue, the value of blue becomes 15, and the value of red stays at 10.
  • If you subtract blue from red, the value of red becomes 5, and the value of blue stays at 5.
  • If you subtract red from blue, the value of blue becomes -5, and the value of red stays at 10.
  • If you multiply red by blue, the value of red becomes 50, and the value of blue stays at 5.
  • If you multiply blue by red, the value of blue becomes 50, and the value of red stays at 10.
  • If you divide red by blue, the value of red becomes 2, and the value of blue stays at 5.
  • If you divide blue by red, the value of blue becomes 0.5, and the value of red stays at 10. 

These values will then apply throughout the rest of the form, unless you change them with another operation. 

Changing the value of a Text variable

You can change the value of Text variables by adding rules in the Branching and calculations menu, in the Logic tab. 

1. Open the branching menu and click + Add rule by the question you want to edit.

2024-07-16_14-08-35.png

2. Switch from “if” to “always” in the first dropdown menu to always change the variable’s value when the question is answered. 

To change its value in certain cases only, choose “if” and add the appropriate condition.

2024-07-16_14-09-41.png

Choose Replace in the dropdown next to Then to change the variable’s value. You can’t do calculations on Text variables, so you won’t be able to choose a math operation.

2024-07-16_14-14-32.png

Then, choose the Text variable to change and type in the new value.

2024-07-16_14-15-57.png

 

HC_BobRoss_ilu_cropped.png
Tip! Text variables can contain alphanumeric characters (a-z, A-Z, 0-9) as well as special characters (&, !, etc.). Even if your text variable contains only numbers, it will be treated as a string of text, and you won’t be able to do calculations with it.

The values of your variables can be changed or displayed throughout your form, whether the respondent has completed your entire form, or submitted a partial response.

Want ideas for using Text variables? Check out this article on creating coupon codes with Text variables.

Tap into our community knowledge