Overview

This article provides a step-by-step guide on how to calculate with user-defined variables in a project. It covers the process of setting up variables, creating input fields, and configuring triggers to perform calculations.

# Information

Learn how to use user-defined variables for calculations within your project, allowing you to sum variables and display the results.

- Setting Up User-Defined Variables
- Creating Input Fields
- Configuring Triggers for Calculations
- Displaying Calculation Results

## Setting Up User-Defined Variables

To begin using user-defined variables for calculations, you need to set them up in your project properties.

### Step 1: Access Project Properties

Navigate to Project -> Properties -> Survey Options -> user-defined variables.

### Step 2: Select Number of Variables

Choose the number of user-defined variables you want to use for your calculations.

## Creating Input Fields

Create input fields to allow users to enter values for the calculation.

### Step 1: Create a Multi Text Field

Add a new question of type multi-text field (143) where users can input different numbers for the calculation.

### Step 2: Set Input Format

For the Input-Format, select "only Floats allowed" to ensure numerical input. Save your changes after setting this option.

## Configuring Triggers for Calculations

Set up triggers to perform the calculations based on user input.

### Step 1: Create a Recording Trigger

Go to your new page -> Triggers -> Create a recording trigger.

### Step 2: Enable Preview Mode Execution

Check the option "Also execute trigger in preview mode".

### Step 3: Configure Calculation

In the detail configuration, choose your defined variable (e.g., c_0001) and insert the calculation formula in the "value" field. For example: #v_1# + #v_2# + #v_3#. You can use operators +, -, /, and * in your calculations.

## Displaying Calculation Results

Create a page to show the results of your calculations.

### Step 1: Create a Result Page

Create a new page, preferably of Type 998 (result page).

### Step 2: Display the Result

In the question text of the result page, use #c_0001# to display the result of the calculation.

# FAQ

### Can I display the individual values used in the calculation?

Yes, you can display the values of the variables used in the calculation. For example, you can write "The result of your calculation #v_1# + #v_2# + #v_3# is: #c_0001#" in the question text to show both the input values and the final result.

### What types of calculations can I perform?

You can perform basic arithmetic operations using the operators +, -, /, and *. More complex calculations may require additional configuration or custom scripting.

## Comments

0 comments

Article is closed for comments.