**Formulas and scripts** are used to create **calculated** **indicators** from indicators inside of BellaDati dataset.

There are four types of indicators defined by formula:

- Formula indicators defined on data set level. These are available in all reports based on this data set.
- Formula indicators defined ad hoc on view level in each report. These are available only for the particular view and belong to the two subcathegories:
- Additional formula defined indicators
- Formulas on date/time axis

## Creating Formulas

Make sure that you are familiar with Displaying Indicators section prior proceeding with **Formulas**.

You can edit **Formulas** only of **Calculated Indicators**. To create **Calculated Indicator**:

- Go to
**Indicators Settings**dialog. - From the left drop-down menu, select New formula indicator
- Change name of the indicator by clicking on the existing name.
- Click on
**Indicator Settings**. - Create/edit formula in
**Formula**window.

Calculated indicators can be determined by **calculator** symbol next to indicator name.

You can leverage **autocomplete** or **lists** of availabe functions for rapid formula development.

See Formula Reference Guide for complete specification of available formulas.

## Editing Formulas

Click on Indicator name in the report to open *Indicator settings* window.

## Formula indicator editor

Formula indicator editor provides you direct results of formula indicator in selected indicator. In order to access formula editor, select option **Formula editor** on Indicator settings dialogue window. Selecting of this option will open new tab of your browser where will be displayed formula indicator editor next to the selected visualisation. Select option **Save** to apply the formula indicator in the visualisation or option **Report **to redirect back to the report (updated formula will be applied in this report):

## DEBUGGING the FORMULAS (ADVANCED OPTION)

In case you need to use more advanced methods to debug your formula. You can use formula.log file, that is present in every BellaDati installation. Please note. You have to have BellaDati on-premise installation to access formula.log file. Path to log file is *YOUR INSTALLATION DIRECTORY/logs/belladati/formula.log*. *YOUR INSTALLATION DIRECTORY* differs according the installation you have made. For Unix installations you can use *less* command to view the formula.log file.

## Aggregation in Calculated Indicators

Notice that *Indicators setting* dialog of **Calculated Indicator** lacks specification of **Members** and **Time** **aggregation**.

This is because you can define it programatically in combination with additional functions.

**Member aggregation** can be defined by suffixing **Indicator** with:

- @SUM for aggregation
- @AVG for average
- @MIN for minimum
- @MAX for maximum
- @MEDIAN for median
- @DC for distinct count

Example: use M_SALES@SUM to obtain Total Sales or M_PRICE@MIN to find the lowest price.

Visit Formula Reference Guide to learn more about aggregations in formulas.