# Basic aggregation functions

Basic aggregation functions are a group of the most common aggregation functions.

Use the drop-down on each function to see a brief description and the syntax of each function. Click the function name in the syntax description for further details.

## Basic aggregation functions in the load script

[](https://help.qlik.com/en-US/qlikview/Subsystems/Client/Content/QV_QlikView/Scripting/AggregationFunctions/basic-aggregation-functions.htm)

#### FirstSortedValue

The sorted values are iterated over a number of records, as defined by a group by clause, or aggregated across the full data set if no group by clause is defined.

[**firstsorted**](https://help.qlik.com/en-US/qlikview/September2026/Subsystems/Client/Content/QV_QlikView/Scripting/AggregationFunctions/firstsorted.htm)([**firstsorted**](https://help.qlik.com/en-US/qlikview/September2026/Subsystems/Client/Content/QV_QlikView/Scripting/AggregationFunctions/firstsorted.htm)**firstsorted**firstsorted([ distinctdistinct ] expression , sort-weight [, n ] ] expression , sort-weight [, n ]))

[](https://help.qlik.com/en-US/qlikview/Subsystems/Client/Content/QV_QlikView/Scripting/AggregationFunctions/basic-aggregation-functions.htm)

#### Max

Max() finds the highest numeric value of the aggregated data in the expression, as defined by a group by clause. By specifying a rank n, the nth highest value can be found.

[**max**](https://help.qlik.com/en-US/qlikview/September2026/Subsystems/Client/Content/QV_QlikView/Scripting/AggregationFunctions/max.htm)([**max**](https://help.qlik.com/en-US/qlikview/September2026/Subsystems/Client/Content/QV_QlikView/Scripting/AggregationFunctions/max.htm)**max**max( expression[, rank] expression[, rank]))

[](https://help.qlik.com/en-US/qlikview/Subsystems/Client/Content/QV_QlikView/Scripting/AggregationFunctions/basic-aggregation-functions.htm)

#### Min

Min() returns the lowest numeric value of the aggregated data in the expression, as defined by a group by clause. By specifying a rank n, the nth lowest value can be found.

[**min**](https://help.qlik.com/en-US/qlikview/September2026/Subsystems/Client/Content/QV_QlikView/Scripting/AggregationFunctions/min.htm)([**min**](https://help.qlik.com/en-US/qlikview/September2026/Subsystems/Client/Content/QV_QlikView/Scripting/AggregationFunctions/min.htm)**min**min( expression[, rank] expression[, rank]))

[](https://help.qlik.com/en-US/qlikview/Subsystems/Client/Content/QV_QlikView/Scripting/AggregationFunctions/basic-aggregation-functions.htm)

#### Mode

Mode() returns the most commonly-occurring value, the mode value, of the aggregated data in the expression, as defined by a group by clause. The Mode() function can return numeric values as well as text values.

[**mode**](https://help.qlik.com/en-US/qlikview/September2026/Subsystems/Client/Content/QV_QlikView/Scripting/AggregationFunctions/mode.htm)([**mode**](https://help.qlik.com/en-US/qlikview/September2026/Subsystems/Client/Content/QV_QlikView/Scripting/AggregationFunctions/mode.htm)**mode**mode(expression expression ))

[](https://help.qlik.com/en-US/qlikview/Subsystems/Client/Content/QV_QlikView/Scripting/AggregationFunctions/basic-aggregation-functions.htm)

#### Only

Only() returns a value if there is one and only one possible result from the aggregated data. If the records within each grouped result as defined by the group by clause contains only one value, then that value is returned. Otherwise NULL is returned

[**only**](https://help.qlik.com/en-US/qlikview/September2026/Subsystems/Client/Content/QV_QlikView/Scripting/AggregationFunctions/only.htm)([**only**](https://help.qlik.com/en-US/qlikview/September2026/Subsystems/Client/Content/QV_QlikView/Scripting/AggregationFunctions/only.htm)**only**only(expression expression ))

[](https://help.qlik.com/en-US/qlikview/Subsystems/Client/Content/QV_QlikView/Scripting/AggregationFunctions/basic-aggregation-functions.htm)

#### Sum

Sum() calculates the total of the values aggregated in the expression, as defined by a group by clause.

[**sum**](https://help.qlik.com/en-US/qlikview/September2026/Subsystems/Client/Content/QV_QlikView/Scripting/AggregationFunctions/sum.htm)([distinct]expression)

## Basic aggregation functions in chart expressions

Chart aggregation functions can only be used on fields in chart expressions. The argument expression of one aggregation function must not contain another aggregation function.

[](https://help.qlik.com/en-US/qlikview/Subsystems/Client/Content/QV_QlikView/Scripting/AggregationFunctions/basic-aggregation-functions.htm)

#### FirstSortedValue

FirstSortedValue() returns the value from the expression specified in value that corresponds to the result of sorting the sort\_weight argument, taking into account rank, if specified. If more than one resulting value shares the same sort\_weight for the specified rank, the function returns NULL.

[**firstsortedvalue**](https://help.qlik.com/en-US/qlikview/September2026/Subsystems/Client/Content/QV_QlikView/ChartFunctions/BasicAggregationFunctions/firstsortedvalue.htm)([{SetExpression}] [DISTINCT] [TOTAL [&lt;fld {,fld}&gt;]] value, sort\_weight [,rank])

[](https://help.qlik.com/en-US/qlikview/Subsystems/Client/Content/QV_QlikView/Scripting/AggregationFunctions/basic-aggregation-functions.htm)

#### Max

Max() finds the highest value of the aggregated data. By specifying a rank n, the nth highest value can be found.

[**max**](https://help.qlik.com/en-US/qlikview/September2026/Subsystems/Client/Content/QV_QlikView/ChartFunctions/BasicAggregationFunctions/max.htm)([{SetExpression}] [DISTINCT] [TOTAL [&lt;fld {,fld}&gt;]] expr [,rank])

[](https://help.qlik.com/en-US/qlikview/Subsystems/Client/Content/QV_QlikView/Scripting/AggregationFunctions/basic-aggregation-functions.htm)

#### Min

Min() finds the lowest numeric value of the aggregated data. By specifying a rank n, the nth lowest value can be found.

[**min**](https://help.qlik.com/en-US/qlikview/September2026/Subsystems/Client/Content/QV_QlikView/ChartFunctions/BasicAggregationFunctions/min.htm)([{SetExpression}] [DISTINCT] [TOTAL [&lt;fld {,fld}&gt;]] expr [,rank])

[](https://help.qlik.com/en-US/qlikview/Subsystems/Client/Content/QV_QlikView/Scripting/AggregationFunctions/basic-aggregation-functions.htm)

#### Mode

Mode() finds the most commonly-occurring value, the mode value, in the aggregated data. The Mode() function can process text values as well as numeric values.

*[**mode**](https://help.qlik.com/en-US/qlikview/September2026/Subsystems/Client/Content/QV_QlikView/ChartFunctions/BasicAggregationFunctions/mode.htm)*({[SetExpression] [TOTAL [&lt;fld {,fld}&gt;]]} expr)

[](https://help.qlik.com/en-US/qlikview/Subsystems/Client/Content/QV_QlikView/Scripting/AggregationFunctions/basic-aggregation-functions.htm)

#### Only

Only() returns a value if there is one and only one possible result from the aggregated data. For example, searching for the only product where the unit price =9 will return NULL if more than one product has a unit price of 9.

[**only**](https://help.qlik.com/en-US/qlikview/September2026/Subsystems/Client/Content/QV_QlikView/Scripting/AggregationFunctions/only.htm)([{SetExpression}] [DISTINCT] [TOTAL [&lt;fld {,fld}&gt;]] expr)

[](https://help.qlik.com/en-US/qlikview/Subsystems/Client/Content/QV_QlikView/Scripting/AggregationFunctions/basic-aggregation-functions.htm)

#### Sum

Sum() calculates the total of the values given by the expression or field across the aggregated data.

[**sum**](https://help.qlik.com/en-US/qlikview/September2026/Subsystems/Client/Content/QV_QlikView/ChartFunctions/BasicAggregationFunctions/sum.htm)([{SetExpression}] [DISTINCT] [TOTAL [&lt;fld {,fld}&gt;]] expr])