## How to create a formula

Go to

**Formulas**>**+ New formula**.Give your formula a title. You'll be able to find the formula by its title in the formula list, on dashboards, in reports, and other places where formulas are used.

Click

**+ New component**. You can add as many components as needed.Choose what your component should do. To calculate data from a data source, choose

**Data function**(top-left corner). You can also use an existing formula, create a group (parentheses), add a date function, or enter a static number.If you chose

**Data function**, the next step is to select a**Function**. This will tell Plecto how to calculate your data.

(Optional) Adjust the

**Date field**. By default, the formula will refer to the default date fields of the used data sources, but you can change that in each individual formula.(Optional) Click

**+ Add filter**to get specific data. For example, to only see the number of outgoing calls.(Optional) Repeat steps 3 – 7 if needed. Feel free to combine data from different data sources.

Check the

**Number format**. If you expect to see text, percentage, date, duration, or other formats on a widget, make sure to choose the matching number format.(Optional) Add conditional colors. For example, if you add 0 (red) – 50 (yellow) – 100 (green), the widget will show your data in red between 0 and 49, yellow between 50 and 99, and green when you reach 100 and more.

(Optional) Add a prefix of suffix.

Click

**Save**to finish.

## What are the different functions?

Data functions tell Plecto how to calculate your data:

**Sum of**sums all the values from a specific field in a data source. For example, if you want to calculate the total value, you should use this function.**Number of**calculates how many registrations there are in the data source.**Number of unique**calculates how many unique registrations there are in a specific field in a data source. For example, if there are 2000 registrations of the products you've sold, but you only sell 3 different kinds of products, the formula will return 3.**First**will find the very first (oldest) registrations in your data source.**Last**will find the latest (newest) registrations in your data source.**Min**will find the smallest value in a specific field.**Max**will find the highest value in a specific field.**Avg**will calculate the average value from a specific field.