Summary Level Aggregations
- 2 minutes to read
The Dashboard controls aggregate data when you construct a calculated field expression. This allows you to evaluate calculated fields on a summary level.
Use the following set of predefined aggregate functions to create aggregated expressions:
- Avg(Value)
Returns the average of all the values in the expression.
Avg([Profit])
- Count()
Returns the number of values.
Count()
- CountNotNull(Value)
Returns a number of non-null objects in a collection.
CountNotNull([Orders])
- CountDistinct(Value)
Returns the number of distinct values.
CountDistinct([Orders])
- FirstValue()
Returns the first value from rows used to calculate an aggregate value.
FirstValue([ProductName])
- Max(Value)
Returns the maximum value across all records.
Max([Profit])
- Min(Value)
Returns the minimum value across all records.
Min([Profit])
- Mode(Value)
Returns the mode of the values.
Mode([Profit])
- Median(Value)
Returns the median of the values.
Median([Profit])
- Sum(Value)
Returns the sum of all values.
Sum([Profit])
- Var(Value)
Returns an estimate of the variance of a population, where the sample is a subset of the entire population.
Var([Orders])
- Varp(Value)
Returns the variance of a population, where the population is the entire data to be summarized.
Varp([Orders])
- StdDev(Value)
Returns an estimate of the standard deviation of a population, where the sample is a subset of the entire population.
StdDev([Orders])
- StdDevp(Value)
Returns the standard deviation of a population, where the population is the entire data to be summarized.
StdDevp([Orders])
These functions can be used for all types of numeric fields. After creating such calculated fields, you can use them as measures contained in an OLAP cube.
The following code snippet shows how to create a Margin calculated field for desktop dashboard controls. The field is based on the Profit and Revenue data source fields:
using DevExpress.DashboardCommon;
//...
CalculatedField margin = new CalculatedField("Sum([ProfitYTDTarget]) / Sum([RevenueYTDTarget])");
margin.DataType = CalculatedFieldType.Decimal;
margin.Name = "Margin";
DashboardViewer.Dashboard.DataSources[2].CalculatedFields.Add(margin);
Note
You can find the created calculated fields in the WinForms Designer’s data source browser or on the Web Dashboard’s Data Sources page.