Defining the aggregation scope
There are usually two factors that together determine which records are used to define the value of aggregation in an expression. When working in visualizations, these factors are:
- Dimensional value (of the aggregation in a chart expression)
- Selections
Together, these factors define the scope of the aggregation. You may come across situations where you want your calculation to disregard the selection, the dimension or both. In chart functions, you can achieve this by using the TOTAL qualifier, set analysis, or a combination of the two.
Method | Description |
---|---|
TOTAL qualifier |
Using the total qualifier inside your aggregation function disregards the dimensional value. The aggregation will be performed on all possible field values. The TOTAL qualifier may be followed by a list of one or more field names within angle brackets. These field names should be a subset of the chart dimension variables. In this case, the calculation is made disregarding all chart dimension variables except those listed, that is, one value is returned for each combination of field values in the listed dimension fields. Also, fields that are not currently a dimension in a chart may be included in the list. This may be useful in the case of group dimensions, where the dimension fields are not fixed. Listing all of the variables in the group causes the function to work when the drill-down level changes. |
Set analysis | Using set analysis inside your aggregation overrides the selection. The aggregation will be performed on all values split across the dimensions. |
TOTAL qualifier and set analysis |
Using the TOTAL qualifier and set analysis inside your aggregation overrides the selection and disregards the dimensions. |
ALL qualifier |
Using the ALL qualifier inside your aggregation disregards the selection and the dimensions. The equivalent can be achieved with the {1} set analysis statement and the TOTAL qualifier: =sum(All Sales) =sum({1} Total Sales) |
Example: TOTAL qualifier
The following example shows how TOTAL can be used to calculate a relative share. Assuming that Q2 has been selected, using TOTAL calculates the sum of all values disregarding the dimensions.
Year | Quarter | Sum(Amount) | Sum(TOTAL Amount) | Sum(Amount)/Sum(TOTAL Amount) |
---|---|---|---|---|
3000 | 3000 | 100% | ||
2012 | Q2 | 1700 | 3000 | 56,7% |
2013 | Q2 | 1300 | 3000 | 43,3% |
Example: Set analysis
The following example shows how set analysis can be used to make a comparison between data sets before any selection was made. Assuming that Q2 has been selected, using set analysis with the set definition {1} calculates the sum of all values disregarding any selections but split by the dimensions.
Year | Quarter | Sum(Amount) | Sum({1} Amount) | Sum(Amount)/Sum({1} Amount) |
---|---|---|---|---|
3000 | 10800 | 27,8% | ||
2012 | Q1 | 0 | 1100 | 0% |
2012 | Q3 | 0 | 1400 | 0% |
2012 | Q4 | 0 | 1800 | 0% |
2012 | Q2 | 1700 | 1700 | 100% |
2013 | Q1 | 0 | 1000 | 0% |
2013 | Q3 | 0 | 1100 | 0% |
2013 | Q4 | 0 | 1400 | 0% |
2013 | Q2 | 1300 | 1300 | 100% |
Example: TOTAL qualifier and set analysis
The following example shows how set analysis and the TOTAL qualifier can be combined to make a comparison between data sets before any selection was made and across all dimensions. Assuming that Q2 has been selected, using set analysis with the set definition {1} and the TOTAL qualifier calculates the sum of all values disregarding any selections and disregarding the dimensions.
Year | Quarter | Sum(Amount) | Sum({1} TOTAL Amount) | Sum(Amount)/Sum({1} TOTAL Amount) |
---|---|---|---|---|
3000 | 10800 | 27,8% | ||
2012 | Q2 | 1700 | 10800 | 15,7% |
2013 | Q2 | 1300 | 10800 | 12% |
Data used in examples:
AggregationScope:
LOAD * inline [
Year Quarter Amount
2012 Q1 1100
2012 Q2 1700
2012 Q3 1400
2012 Q4 1800
2013 Q1 1000
2013 Q2 1300
2013 Q3 1100
2013 Q4 1400] (delimiter is ' ');
Did this page help you?
If you find any issues with this page or its content – a typo, a missing step, or a technical error – let us know how we can improve!