This article describes how to perform basic mathematical functions on variables in Displayr using the **Calculation** menu. These functions include Divide, Multiply, Subtract, Average, Sum, Maximum, Minimum, Any of, None of, Count, Standard Deviation, and Variance.

For details of each mathematical calculation and options see Mathematical Calculations on Tables and Variables.

## Requirements

Please note these steps require a **Displayr **license.

- A Displayr document with a data set.
- Numeric variables. In this example, we have a numeric grid variable set called
*Q2 - No. of colas consumed*which we will use for these calculations:

## Method - Divide, Multiply, Subtract

1. Select one or two variables in the **Data Sets** tree that you wish to use in your calculation. For example, let's select the *Coca-Cola - When 'out and about'* and *Coca-Cola - When 'at home'* variables. Note, the order you select these variables determines where they are placed in the calculation.

2. Go to **Insert a new Calculation () >**in the toolbar and select **Divide**, **Multiply** or **Subtract**.

3. A new variable will be created directly after the selected variable set(s) which applies the specified formula on the selected variable(s).

4. OPTIONAL: When you select the new variable, in the **object inspector** it will display the variables that have been used. You can change the variables by using the relevant drop-down.

5. OPTIONAL: If you only select a single variable, it will default to a **Single numeric value** of **1** for the second reference. You can change this value as required to update your calculation.

6. OPTIONAL: You can additionally switch either reference between a **Variable** and a** Single numeric value** if required.

Note, if you perform this on nominal variables, the calculation will use the underlying values.

## Method - Average, Sum, Maximum, Minimum, Any of, None of, Count, Standard Deviation, Variance

1. Select the variables in **Data Sources** that you wish to use in your calculation. For example, let's select all the *Coca-Cola *variables from the* When 'out and about'* group. Note, the order you select these variables determines where they are placed in the calculation.

2. Go to **Insert a new Calculation ()** in the toolbar and select** Average**, **Sum**,** Maximum**, **Minimum**, **Any of**, **None of**, **Count**, **Standard Deviation **or **Variance **in both sub-menus, e.g. **Average > Average**.

3. A new variable will be created directly after the selected variable set(s) which applies the specified formula on the selected variable(s).

4. OPTIONAL: When you select the new variable, in the **object inspector** it will display the variables that have been used. You can change, remove or add to the variables drop-down as required:

5. OPTIONAL: In **Calculate for observations with incomplete data** if set to 'Yes', any missing values are removed from the data before the calculation occurs. Ig set to 'No', cases with any missing values will be assigned a missing value. Cases whose values are entirely missing, will always be assigned a missing value regardless of this setting.

6. OPTIONAL: For the **Any of**, **None of** and **Count** options where you are working with numeric data, you can additionally adjust **Values to count**. This takes the format of individual specified values or a range of values, e.g. *0-10* or *1,2,3* or *>1*. When working with categorical data, you instead specify the **Categorical labels** to include.

## Next

How to Create a Custom R Text Variable

How to Create a Custom Numeric R Variable

How to Perform Mathematical Calculations on Tables

How to Perform Mathematical Calculations Using R

Bespoke Analyses and Calculations