View on GitHub

dotnet-eud

.NET Controls End-User Documentation

Intermediate Level Aggregations

The Dashboard can aggregate and summarize data on different levels.

Overview

The Aggr function aggregates and summarizes underlying data using the detail level specified by a predefined set of dimensions and a specified summary function. This function can be used during the creation of a new calculated field in the Expression Editor.

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 the increased or decreased granularity to the dashboard item. There are two main scenarios.

Example 1 - Best/Worst Sales by Year

The following example shows how to display best and worst monthly sales for each year.

In this example, the Chart dashboard item shows the sum of sales by different years. The Sales field is placed in the Values section and the OrderDate (with the Year group interval) is placed in the Arguments section.

Aggr_Example1_SalesByYear

To display sales by the best/worst months for each year, create a new calculated field with the following expression.

Aggr(Sum([Sales]), GetYear([OrderDate]), GetMonth([OrderDate]))

Drop this field (Sales by Year/Month in the image below) to the Values section and set its summary type to Max. Then, drop this field to Values again and set its summary type to Min. The Chart will visualize sales by the best/worst months in a year.

Aggr_Example1_SalesByMonths

Example 2 - Percent of Total

This example will demonstrate how to calculate a contribution of individual quarter sales to year sales.

In this example, the Pivot dashboard item displays the sum of sales by year/quarter. The Sales field is placed in the Values section and the hierarchy of OrderDate fields (with the Year and Quarter group intervals) is placed in Rows.

Aggr_Example2_SalesByQuarterYear

To calculate a contribution of each quarter to a year sales, do the following.

Aggr_Example2_SalesByQuarterYear_PercentOfTotal

Example 3 - Customer Acquisition

In this example, a customer acquisition will be evaluated by grouping customers by the quarter/year of their first purchase to compare sales contributions.

The Chart dashboard item below visualizes sales by quarter/year.

Aggr_Example3_CohortAnalysis

The following expression determines the minimum order date (the first purchase date) per customer.

Aggr(Min(GetDateQuarterYear([OrderDate])), [CustomerID])

Set the name of the created field to Customer First Order and drop this field to the Series section to see the result.

Aggr_Example3_CohortAnalysis_Result

Example 4 - Customer Order Count

In this example, you will learn how to divide customers count by the number of orders they made.

The Chart below shows the number of orders that is made by each customer.

Aggr_Example4_CustomerOrderCount

The calculated field below evaluates the number of unique orders made by each customer.

Aggr(CountDistinct([OrderID]), [CustomerID])

Set the name of this field to Customer Order Count and drop this field to arguments. Then, drop the CustomerID field to Values and change its summary type to Count Distinct.

Aggr_Example4_CustomerOrderCount_Result

The Chart will show the number of customers that made a specific number of orders.

Example 5 - Best Product Sales by Year

This scenario requires the use of nested aggregations. In this example, the dashboard will show products with the best sales in a year along with sales values.

The initial Grid dashboard item shows sales of all products by year (the OrderDate column with the Year group interval and the Sales column). The data source also contains the ProductName field.

Aggr_Example5_SalesByYear

To implement this scenario, perform the following steps.

Aggr_Example5_BestProductByYear_Result