Finally, you can create custom aggregations at different levels and combine these aggregations with existing visualisations. This can be done using the Aggr function that aggregates and summarises underlying data using the detail level specified by a predefined set of dimensions and a specified summary function. The Aggr function has the following syntax.
|
||
Aggr(summaryExpression, dimension1, dimension2, ...)
|
The first argument is a summary expression calculated against a specific data source field. The next arguments are the set of dimensions whose values are aggregated and used to calculate summaries specified using the first argument. For instance, the following function calculates sums of sales for each product within the specified category.
|
||
Aggr(Sum([Sales]), [Category], [Product])
|
If you created the calculated field that includes the Aggr function and dropped the created field into an existing dashboard item, the Dashboard joins the resulting aggregation with the already displayed data. This means that you can add data with increased or decreased granularity to the dashboard item. There are two main scenarios.
In the first scenario, an aggregation has a less detailed granularity than visualised data.
In this scenario, an underlying data source contains the list of orders for two categories and corresponding products.
To aggregate this data by individual categories, create a calculated field with the following expression.
|
||
Aggr(Sum([Sales]), [Category])
|
The following internal table will be generated for this calculated field.
The sample Grid dashboard item contains more detailed data and includes the following columns: Category, Product and the sum of Sales.
If you drop the created calculated field to the Grid, the sum of sales for each category will be repeated for each Grid row.
For instance, you can use these values later to calculate the contribution of each product to a category’s sales.
An aggregation has a more detailed granularity than visualised data.
To aggregate this data by categories and products, create a calculated field with the following expression.
|
||
Aggr(Sum([Sales]), [Category], [Product])
|
The following internal table will be generated for this calculated field.
Drop the created calculated field to the Grid and set its summary type to Min. The Grid will display minimum product sales within each category.