# Add calculations

This topic describes how to add a calculation by typing it or by using a predefined function. For details about how to use a script, see Add script calculations.

When adding a calculation, consider the following aspects:

- You can add calculations when you create a dataset. These calculations can be used for all the visualizations that are based on that dataset.
- You can also add calculations when you work with a visualization. These calculations can be used only for the visualization for which they were defined. If you want to reuse such a calculation in a different visualization, you can duplicate the widget. In the duplicated widget, the calculation will be available for selection. For details on how to duplicate a widget, see Manage widgets.

###### Prerequisites

- You are creating a dataset,
or you added a visualization to a storyboard page . See also About calculations.

###### Procedure

Depending on the page, do one of the following:

On Step 2 – Refine, select a data source, and then click Calculations.

On Step 3 – Join and preview, next to the data source name, click More options, and then Calculations.

The Calculations dialog appears.

- In the Calculation name field, type a name for the calculation.
Select whether the new calculation is a date, DateTime, time, dimension, geo dimension, measure, or aggregated measure (where you aggregate the data directly in the calculation).

In the Type calculation field, add the calculation using the following options:

To add a column from the dataset, drag the column from the Dimensions or Measures sections.

To add a function, drag it from the functions list. Then, write the function's expression between parentheses.

To view details about a function, click it in the functions list. The function syntax and description appear below the functions list. See also Functions & macros.

Click Save.

The calculation column is added to the dataset.

Ensure that the storyboard with the visualization is in edit mode. For details, see Storyboard view modes.

Point to the upper-right corner of the widget where you want to add the calculation.

The widget toolbar appears.

Point to Edit, and then click Edit settings.

The widget settings pane appears.

- On the data tab, expand the Data section.
Point to the data field for which you want to create a calculation, and then click Add calculation.

The Calculations pane appears.

- In the Calculation name field, type a name for the calculation.
Select whether the new calculation is a date, DateTime, time, dimension, geo dimension, measure, or aggregated measure (where you aggregate the data directly in the calculation).

In the Type calculation field, add the calculation using the following options:

To add a column from the dataset, drag the column from the Dimensions or Measures sections.

To add a function, drag it from the functions list. Then, write the function's expression between parentheses.

To view details about a function, click it in the functions list. The function syntax and description appear below the functions list. See also Functions & macros.

Click Save.

The calculation is added to the data field for which it was created. You can use the new calculation like any other measure or dimension to fill in the visualization data fields.

## Comments

0 comments