[]
Aggregation functions calculate a scalar value such as count, sum, average, minimum, or maximum over a column or table, based on the defined expression. These functions are commonly used in calculated fields, measures, and data modeling scenarios to summarize data.
Wyn Enterprise supports the following aggregation functions:
Returns the average (arithmetic mean) of all the numbers in a column.
AVERAGE(<column>)Parameter | Description |
|---|---|
column | The column that contains the numbers for which you want the average. |
A decimal number.
AVERAGE('Sale'[Price])AVERAGE calculates the mean of numeric values in the specified column.
Text values return blanks.
Logical values and empty cells are ignored.
Zero values are included in the calculation.
If no rows exist, the function returns blank.
If rows exist but do not meet criteria, the function returns 0.
Related Function
AVERAGE is a simplified version of AVERAGEX.
Calculates the average (arithmetic mean) of a set of expressions evaluated over a table.
AVERAGEX(<table>, <expression>)Parameter | Description |
|---|---|
table | The table or table expression over which aggregation is performed. |
expression | A scalar expression evaluated for each row. |
A decimal number.
AVERAGEX('Sale', 'Sale'[Price] * 'Sale'[Quantity])AVERAGEX evaluates the expression row by row, then computes the average of the results.
It follows the same rules as AVERAGE regarding blanks and non-numeric values.
Counts the number of non-blank values in a column.
COUNT(<column>)A whole number.
Counts numbers, dates, and strings.
Returns blank if no rows are found.
Counts the number of rows in a table or table expression.
COUNTROWS(<table>)Similar to:
SELECT COUNT(1) FROM TableReturns blank if no rows exist.
Counts rows where an expression evaluates to a non-blank value.
COUNTX(<table>, <expression>)An integer.
Evaluates the expression for each row and counts non-blank results.
Counts the number of distinct values in a column.
DISTINCTCOUNT(<column>)Counts BLANK values as distinct.
Counts the number of distinct non-blank values returned by an expression evaluated over a table.
DISTINCTCOUNTX(<table>, <expression>)Does not count BLANK values.
Returns the largest value in a column.
MAX(<column>)Simplified version of MAXX.
Evaluates an expression for each row of a table and returns the largest value.
MAXX(<table>, <expression>)Counts numbers, text, and dates.
Skips blank values.
Returns the smallest value in a column.
MIN(<column>)Simplified version of MINX.
Counts numbers, text, dates, and blanks.
Returns the smallest value resulting from evaluating an expression for each row of a table.
MINX(<table>, <expression>)Adds all numbers in a column.
SUM(<column>)Simplified version of SUMX.
Returns the sum of an expression evaluated for each row in a table.
SUMX(<table>, <expression>)Ignores blanks, logical values, and text.
The AGGX function calls a database-specific aggregation function to compute an aggregated result.
Unlike built-in aggregation functions such as SUM or AVERAGE, AGGX allows you to invoke the corresponding aggregation function supported by the underlying database engine.
AGGX(<table>, <aggregateFunctionName>, <expression>)Parameter | Description |
|---|---|
table | The table containing the rows for which the expression will be evaluated. |
aggregateFunctionName | The name of the database-specific aggregation function to call. |
expression | The expression evaluated for each row of the table. |
The return value depends on the corresponding aggregation function defined by the database.
AGGX('Sale', "SUM", 'Sale'[Price] * 'Sale'[Quantity])In this example, AGGX calls the database SUM aggregation function on the evaluated expression.
AGGX evaluates the expression for each row in the specified table.
It then passes the evaluated results to the named database aggregation function.
The supported aggregate function names depend on the underlying database provider.
The return type depends entirely on the database aggregation function being invoked.
Use AGGX when:
A required aggregation is supported by the database but not directly exposed as a built-in WAX function.
You need to explicitly control which database aggregation function is used.
You are working in scenarios requiring database-native aggregation behavior.