# Aggregates

This visualization summarizes data by categories, showing totals, averages, and other key metrics.

<figure><img src="https://300211688-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FQuYbJ9bg7CFtrBaVp9pB%2Fuploads%2F2xJ9VzkeV8AdY6s4fx3j%2Fimage.png?alt=media&#x26;token=7a355aee-d9a8-4081-96a3-0fd51a642428" alt=""><figcaption></figcaption></figure>

### Name of Visualization

Enter the name of your Visualization widget, which will appear on your dashboard.

<figure><img src="https://300211688-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FQuYbJ9bg7CFtrBaVp9pB%2Fuploads%2FTnOD2uN2NUjojyeg6DXQ%2Fimage.png?alt=media&#x26;token=d0f5270c-e728-4dcf-8d0f-862ab61105da" alt=""><figcaption></figcaption></figure>

### Aggregate Type

You can choose between grouped and single aggregate. In grouped aggregate, you can view multiple metrics within a single widget.

<figure><img src="https://300211688-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FQuYbJ9bg7CFtrBaVp9pB%2Fuploads%2Fqutv3P2f0bjrM8R5sGlE%2Fimage.png?alt=media&#x26;token=f4b96d9a-e953-45ce-9dc1-11f48c5e7d3f" alt=""><figcaption></figcaption></figure>

### Aggregates

Enter the following values for each of the metric required.

<figure><img src="https://300211688-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FQuYbJ9bg7CFtrBaVp9pB%2Fuploads%2F5YgGC97IxIw4hZDPzSf8%2Fimage.png?alt=media&#x26;token=02c0abd9-b6d8-42a9-9181-0fbb575e6e42" alt=""><figcaption></figcaption></figure>

### Alias

Enter the name for each metric, which will appear on your dashboard.

### Properties

Select the column name from the dropdown for which you want to get the aggregate.

### Expression Builder

Start typing the function you want to use and select it from the suggestions. Then, place the cursor inside the brackets and type the property name you selected in Properties as the function parameter for calculations. The aggregate function will be applied on the output of this expression builder.

The following options are available in the Expression Builder. `Ci` represents the attributes/properties selected by you

{% tabs %}
{% tab title="Arithmetic Functions" %}

<table><thead><tr><th width="172">Function</th><th width="287">Attribute Structure</th><th>Usage</th></tr></thead><tbody><tr><td>sum()</td><td>(attribute)</td><td>sum(C1)</td></tr><tr><td>sumIf()</td><td>(attribute, filter)</td><td>sumIf(C1, conditions)</td></tr><tr><td>avg()</td><td>(attribute)</td><td>avg(C1)</td></tr><tr><td>avgIf()</td><td>(attribute, filter)</td><td>avgIf(C1, conditions)</td></tr><tr><td>count()</td><td>(attribute)</td><td>count(C1)</td></tr><tr><td>countIf()</td><td>(attribute, filter)</td><td>countIf(C1, conditions)</td></tr><tr><td>uniq()</td><td>(attribute)</td><td>uniq(C1)</td></tr><tr><td>uniqIf()</td><td>(attribute, filter)</td><td>uniqIf(C1, conditions)</td></tr><tr><td>min()</td><td>(attribute)</td><td>min(C1)</td></tr><tr><td>max()</td><td>(attribute)</td><td>max(C1)</td></tr><tr><td>least()</td><td>(attribute1, attribute2)</td><td>least(C1, C2)</td></tr><tr><td>greatest()</td><td>(attribute1, attribute2)</td><td>greatest(C1, C2)</td></tr><tr><td>date_diff()</td><td>(return type, attribute1, attribute2)</td><td>date_diff('second', C1, C2)</td></tr></tbody></table>
{% endtab %}

{% tab title="Operators" %}

<table><thead><tr><th width="125" align="center">Operator</th><th>Action</th><th>Example Usage</th></tr></thead><tbody><tr><td align="center">+</td><td>Addition</td><td>uniq(C1) + uniq(C2)</td></tr><tr><td align="center">-</td><td>Subtraction</td><td>uniq(C1) - uniq(C2)</td></tr><tr><td align="center">/</td><td>Division</td><td>uniq(C1) / uniq(C2)</td></tr><tr><td align="center">*</td><td>Multiplication</td><td>uniq(C1) * uniq(C2)</td></tr></tbody></table>
{% endtab %}

{% tab title="Numeric Transformations" %}

<table><thead><tr><th width="122">Function</th><th width="346">Description</th><th>Usage</th></tr></thead><tbody><tr><td>abs()</td><td>Return the absolute value of a number</td><td>abs(C1)</td></tr><tr><td>toInt8()</td><td>Converts a value to an 8-bit integer</td><td>toInt8(C1)</td></tr><tr><td>toInt16()</td><td>Converts a value to an 16-bit integer</td><td>toInt16(C1)</td></tr><tr><td>toInt32()</td><td>Converts a value to an 32-bit integer</td><td>toInt32(C1)</td></tr><tr><td>toInt64()</td><td>Converts a value to an 64-bit integer</td><td>toInt64(C1)</td></tr><tr><td>toString()</td><td>Converts a value to a string</td><td>toString(C1)</td></tr></tbody></table>
{% endtab %}

{% tab title="Transformations" %}

| Function      | Description                                          | Usage           |
| ------------- | ---------------------------------------------------- | --------------- |
| toTimeStamp() | Converts a value to timestamp                        | toTimeStamp(C1) |
| toWeekDay()   | Converts a date to the corresponding day of the week | toWeekDay(C1)   |
| toUTCHour()   | Converts a time to its UTC Hour                      | toUTCHour(C1)   |
| toMonth()     | Converts a date to its corresponding month           | toMonth(C1)     |
| toDate()      | Converts a value to a date format                    | toDate(C1)      |
| {% endtab %}  |                                                      |                 |
| {% endtabs %} |                                                      |                 |

<figure><img src="https://300211688-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FQuYbJ9bg7CFtrBaVp9pB%2Fuploads%2FTplvUVV9CRPZ2r0Ee816%2Fimage.png?alt=media&#x26;token=8bd5b5bb-9695-496d-8fba-6e9de983b53e" alt=""><figcaption></figcaption></figure>

### Units

Select the unit from the dropdown for your aggregate value to be displayed on the dashboard.

Following unit options are available

{% tabs %}
{% tab title="Time" %}
Second = sec

Minutes = mins

Hours = hrs

Days = days

Week = week
{% endtab %}

{% tab title="Numbers" %}
Thousand = K

Lakh = L

Million = M

Billion = B
{% endtab %}
{% endtabs %}

### Final Transformation

Select whether you want to convert seconds or milliseconds to timestamp format on the dashboard.

### Custom Filters

You can filter the data in the final output on the dashboard according to your needs.

Choose whether to include data using the **=** operator or exclude it using the **!=** operator. You can also use the regex operator and provide the regex formula.

### Customize

You can customize the font size and text color for Alias, Value and the Unit displayed on the dashboard.

### View Chart

Click on View Chart to preview it before adding it to the dashboard.
