# Metrics

### Aggregation Formulas

You can create new metrics from your data source by writing a <mark style="color:blue;">**Aggregation Formula**</mark> to calculate a **Column** in the data source.

Use <mark style="color:blue;">**Table**</mark> to create, name and calculate a new metric:

* Click **`+`** to create a new metric

<figure><img src="https://133649292-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FIYMCWeQmo9kVg5C6SOyv%2Fuploads%2Fb2VxQrZZIYfsCuIcfLmm%2Fimage.png?alt=media&#x26;token=96fc98e2-727a-4ee9-b3d0-5485730ad151" alt=""><figcaption><p>Create a new metric</p></figcaption></figure>

* Type the new metric name and click **`Create metric`**:

<figure><img src="https://133649292-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FIYMCWeQmo9kVg5C6SOyv%2Fuploads%2FjFgJIXSWCiMlZURW6Eap%2Fimage.png?alt=media&#x26;token=59f3d84e-8301-4ead-85ea-6662ebf6272f" alt=""><figcaption><p>Name the new metric</p></figcaption></figure>

* **`Ctrl+Double-click`** and type **`=`** to use <mark style="color:blue;">**Aggregation Formulas**</mark>

<figure><img src="https://133649292-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FIYMCWeQmo9kVg5C6SOyv%2Fuploads%2F6tGeR94Hqqyj3OQrLoEb%2Fimage.png?alt=media&#x26;token=76399333-56cb-41d0-8f81-375f64f7905e" alt=""><figcaption><p>Aggregation Formulas</p></figcaption></figure>

* Choose a <mark style="color:blue;">**Formula**</mark> and type the **correct column name** to find the column from the raw data table (data source)

<figure><img src="https://133649292-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FIYMCWeQmo9kVg5C6SOyv%2Fuploads%2FPOz7Rj2OQqicyQk89I4D%2Fimage.png?alt=media&#x26;token=690d2492-6504-42a2-a9fa-68f963903d09" alt=""><figcaption><p>Find the correct Column from the data source</p></figcaption></figure>

* If there are many similar column names from many tables appearing in the list and you cannot find the correct column name, you can type table name next to it. This will help to shortlist the column name.

<figure><img src="https://133649292-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FIYMCWeQmo9kVg5C6SOyv%2Fuploads%2FPSc7uRunahIRlbqGnOM9%2Ftao%20metric.gif?alt=media&#x26;token=a184b100-1329-47df-99c2-39e232e2ecdd" alt="" width="563"><figcaption></figcaption></figure>

* Then, define the Date that you want the metric to be calculated based on.

<figure><img src="https://133649292-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FIYMCWeQmo9kVg5C6SOyv%2Fuploads%2Fu55fi5PYSXrMsN4prsLb%2Fimage.png?alt=media&#x26;token=48ffb322-1e5c-43d4-8544-6fbf74f7f69f" alt=""><figcaption></figcaption></figure>

{% hint style="info" %}
If you forget to add the date dimension, the system will help to choose the first date column in your table.
{% endhint %}

* Hit **Enter**, and the formula will be applied to the metric for all time.

### Modeling Formulas

You can also create new metrics by calculating from existing metrics in a <mark style="color:blue;">**Table**</mark> by **`Double-clicking`** at the empty cell and type the existing metrics name

<figure><img src="https://133649292-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FIYMCWeQmo9kVg5C6SOyv%2Fuploads%2F0i6xF2XLC5SLpbQUtEVg%2Fimage.png?alt=media&#x26;token=2d9310c8-3eb7-4ed9-b7bf-7f4151c51595" alt=""><figcaption><p>Modelling a formula</p></figcaption></figure>

### Segment Split

Some metrics can be defined differently in certain periods. <mark style="color:blue;">**For example**</mark>*<mark style="color:blue;">: last year VAT was 8% on top of total sales, this year, VAT has been update to 10% on top of total sales.</mark>*

Spitting segment in Presight helps to defines one metric differently at some specific periods. You can right-click on any cell of the metric, and choose <mark style="color:blue;">**Split Segment Here**</mark>.

<figure><img src="https://133649292-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FIYMCWeQmo9kVg5C6SOyv%2Fuploads%2FX8DoEVbpKAczWxJqrV68%2Fimage.png?alt=media&#x26;token=788a0a64-7623-4979-8396-aea5b56ca2db" alt=""><figcaption></figcaption></figure>

So, from 2023-12, new segment will begin. You can double click at the cell at 2024-01 and start changing the formula.

<figure><img src="https://133649292-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FIYMCWeQmo9kVg5C6SOyv%2Fuploads%2FkpTdhblT7SPppYZjEFsc%2Fimage.png?alt=media&#x26;token=d10a7490-cd62-46b8-a919-a33b02d4b73c" alt=""><figcaption></figcaption></figure>

Once you finish editing formula and hit enter, the new formula will be applied from 2024-01 and forwards.

### Clear Formula

As right-clicking on the cell, you can also clear the formula to start inputting again. Clear Formula is useful when your current formula is too long and too complicated, deleting it manually can be inconvinient.

<figure><img src="https://133649292-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FIYMCWeQmo9kVg5C6SOyv%2Fuploads%2FjyJea7JvwzBdEYFUK9xh%2Fimage.png?alt=media&#x26;token=e4b3f28e-c09c-45c1-b631-fc730f426710" alt=""><figcaption></figcaption></figure>

{% hint style="info" %}
[Check ](#user-content-fn-1)[^1]more about <mark style="color:blue;">**Formulas**</mark> in the documentation below:
{% endhint %}

{% content-ref url="formulas/metric-formulas" %}
[metric-formulas](https://presight.gitbook.io/presight-v1.0/model/formulas/metric-formulas)
{% endcontent-ref %}

[^1]:
