[]
        
(Showing Draft Content)

Aggregation Functions

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:


AVERAGE

Description

Returns the average (arithmetic mean) of all the numbers in a column.

Syntax

AVERAGE(<column>)

Parameters

Parameter

Description

column

The column that contains the numbers for which you want the average.

Return Value

A decimal number.

Example

AVERAGE('Sale'[Price])

Remarks

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.


AVERAGEX

Description

Calculates the average (arithmetic mean) of a set of expressions evaluated over a table.

Syntax

AVERAGEX(<table>, <expression>)

Parameters

Parameter

Description

table

The table or table expression over which aggregation is performed.

expression

A scalar expression evaluated for each row.

Return Value

A decimal number.

Example

AVERAGEX('Sale', 'Sale'[Price] * 'Sale'[Quantity])

Remarks

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.


COUNT

Description

Counts the number of non-blank values in a column.

Syntax

COUNT(<column>)

Return Value

A whole number.

Remarks

Counts numbers, dates, and strings.

Returns blank if no rows are found.


COUNTROWS

Description

Counts the number of rows in a table or table expression.

Syntax

COUNTROWS(<table>)

Remarks

Similar to:

SELECT COUNT(1) FROM Table

Returns blank if no rows exist.


COUNTX

Description

Counts rows where an expression evaluates to a non-blank value.

Syntax

COUNTX(<table>, <expression>)

Return Value

An integer.

Remarks

Evaluates the expression for each row and counts non-blank results.


DISTINCTCOUNT

Description

Counts the number of distinct values in a column.

Syntax

DISTINCTCOUNT(<column>)

Remarks

Counts BLANK values as distinct.


DISTINCTCOUNTX

Description

Counts the number of distinct non-blank values returned by an expression evaluated over a table.

Syntax

DISTINCTCOUNTX(<table>, <expression>)

Remarks

Does not count BLANK values.


MAX

Description

Returns the largest value in a column.

Syntax

MAX(<column>)

Remarks

Simplified version of MAXX.


MAXX

Description

Evaluates an expression for each row of a table and returns the largest value.

Syntax

MAXX(<table>, <expression>)

Remarks

Counts numbers, text, and dates.

Skips blank values.


MIN

Description

Returns the smallest value in a column.

Syntax

MIN(<column>)

Remarks

Simplified version of MINX.

Counts numbers, text, dates, and blanks.


MINX

Description

Returns the smallest value resulting from evaluating an expression for each row of a table.

Syntax

MINX(<table>, <expression>)

SUM

Description

Adds all numbers in a column.

Syntax

SUM(<column>)

Remarks

Simplified version of SUMX.


SUMX

Description

Returns the sum of an expression evaluated for each row in a table.

Syntax

SUMX(<table>, <expression>)

Remarks

Ignores blanks, logical values, and text.


AGGX

Description

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.

Syntax

AGGX(<table>, <aggregateFunctionName>, <expression>)

Parameters

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.

Return Value

The return value depends on the corresponding aggregation function defined by the database.

Example

AGGX('Sale', "SUM", 'Sale'[Price] * 'Sale'[Quantity])

In this example, AGGX calls the database SUM aggregation function on the evaluated expression.

Remarks

  • 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.

When to Use AGGX

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.