Appendix A. Commonly Used DAX Expressions

In this appendix, I will go over the syntax of some of the most commonly used DAX functions in Power BI. These are organized by section, then alphabetically within that section. For each function, there will be a brief description of the purpose of the function, the syntax of the function, and then an example using that syntax.

This is not an exhaustive list of all the functions in the DAX language. That can be reviewed at “DAX Function Reference”.

As with many things, DAX is a prime example of the Pareto principle: 80% of all the problems (outputs) can be solved with 20% mastery (inputs).

Aggregation Functions

AVERAGE

Definition

Returns the average (mean) of all the numerical values of a column.

Syntax

AVERAGE ( [ColumnName] )

Example

AverageScore = AVERAGE ( GradeScore[Score] )

AVERAGEX

Definition

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

Syntax

AVERAGEX ( 'TableName' , <expression> )

Example

AverageScorePercentage = AVERAGEX ( 'GradeScores', 'GradeScores'[Score] + 
  'GradeScores'[MaximumPossibleScore] )

COUNT

Definition

Returns the number of records for a column that are not blank.

Syntax

COUNT ( [ColumnName] )

Example

CountOfStudents = COUNT ( 'UniversitySuppliedData'[StudentID] )

DISTINCTCOUNT

Definition

Returns the number of distinct values for a given column.

Syntax

DISTINCTCOUNT ( [ColumnName] )

Example

 CountOfStudents = DISTINCTCOUNT ( 'GradeScores'[StudentID] ...

Get Learning Microsoft Power BI now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.