Skip to main content Skip to complementary content

Avg - chart function

Avg() returns the aggregated average of the expression or field iterated over the chart dimensions.


Avg([{SetExpression}] [DISTINCT] [TOTAL [<fld{, fld}>]] expr)

Return data type: numeric


  • expr: The expression or field containing the data to be measured.
  • SetExpression: By default, the aggregation function will aggregate over the set of possible records defined by the selection. An alternative set of records can be defined by a set analysis expression.
  • DISTINCT: If the word DISTINCT occurs before the function arguments, duplicates resulting from the evaluation of the function arguments are disregarded.
  • TOTAL: If the word TOTAL occurs before the function arguments, the calculation is made over all possible values given the current selections, and not just those that pertain to the current dimensional value, that is, it disregards the chart dimensions. The TOTAL qualifier may be followed by a list of one or more field names within angle brackets <fld>. These field names should be a subset of the chart dimension variables.

    Defining the aggregation scope


The parameter of the aggregation function must not contain other aggregation functions, unless these inner aggregations contain the TOTAL qualifier. For more advanced nested aggregations, use the advanced function Aggr, in combination with a specified dimension.


Examples and results
Example Result

For a table including the dimension Customer and the measure Avg([Sales]), if Totals are shown, the result is 2566.

Avg([TOTAL (Sales)) 53.458333 for all values of Customer, because the TOTAL qualifier means that dimensions are disregarded.
Avg(DISTINCT (Sales)) 51.862069 for the total, because using the Distinct qualifier means only unique values in Sales for each Customer are evaluated.
Example output in table form
Customer Sum(Sales) Avg(Sales) Avg(TOTAL Sales) Avg(DISTINCT Sales) Avg({1}DISTINCT Sales)
- 2566 53.46 53.458333 51.862069 53.458333
Astrida 587 48.92 53.458333 43.1 53.458333
Betacab 539 44.92 53.458333 43.909091 53.458333
Canutility 683 56.92 53.458333 55.909091 53.458333
Divadip 757 63.08 53.458333 61 53.458333

Data used in examples:



Month, Monthnumber

Jan, 1

Feb, 2

Mar, 3

Apr, 4

May, 5

Jun, 6

Jul, 7

Aug, 8

Sep, 9

Oct, 10

Nov, 11

Dec, 12



crosstable (Month, Sales) LOAD * inline [






] (delimiter is '|');

To get the months to sort in the correct order, when you create your charts, go to the Sort tab of the chart properties, and mark the checkbox Expression under Sort by. In the expression box write Monthnumber.

Example data in table form
Customer Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec
Astrida 46 60 70 13 78 20 45 65 78 12 78 22
Betacab 65 56 22 79 12 56 45 24 32 78 55 15
Canutility 77 68 34 91 24 68 57 36 44 90 67 27
Divadip 57 36 44 90 67 27 57 68 47 90 80 94

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!

Join the Analytics Modernization Program

Remove banner from view

Modernize without compromising your valuable QlikView apps with the Analytics Modernization Program. Click here for more information or reach out: