Skip to content

Chapter 3 of 6

Iterator, Aggregation, and Lookup Functions

Iterator functions evaluate an expression for each row of a table and then aggregate the results into a single value. Common iterators include SUMX, AVERAGEX, MINX, MAXX, COUNTX, and COUNTAX. For example, SUMX(Sales, Sales[Qty] * Sales[Price]) computes revenue per transaction before summing. The key distinction between SUM and SUMX is that SUM aggregates a single column directly, while SUMX can evaluate multi-column expressions row by row. AVERAGEX likewise produces a row-by-row average, supporting conditional or weighted averages that a simple AVERAGE cannot. COUNTROWS counts the rows of a table expression and is the recommended way to count records after filtering, while COUNT counts only numeric values and COUNTA counts non-blank cells including text and dates.

Several functions retrieve values across tables. RELATED pulls a column value from a related table when a many-to-one relationship exists, working only inside row context such as a calculated column or an iterator. RELATEDTABLE returns all rows on the many side of a relationship that relate to the current row, useful for counting or aggregating related transactions. LOOKUPVALUE retrieves a value from a column based on one or more search conditions without requiring an active relationship, which is convenient when working with unrelated tables, though RELATED is preferred when a relationship exists.

Other frequently used functions include FILTER, which returns a subset of a table matching a Boolean condition and is commonly nested inside CALCULATE to introduce complex dynamic filters. DIVIDE performs division with an optional alternate result when the denominator is zero, avoiding #DIV/0! errors. SELECTEDVALUE returns the value of a column when exactly one value is selected in the filter context, otherwise returning an alternate result, and is shorthand for the IF(HASONEVALUE(...), VALUES(...), alternate) pattern. HASONEVALUE and HASONEFILTER are companion functions used to detect single selections, while ISBLANK checks for blanks, BLANK returns a blank, and COALESCE returns the first non-blank among its arguments. SWITCH evaluates an expression against multiple values, providing a cleaner alternative to nested IF statements.

All chapters
  1. 1Foundations of DAX and Calculation Types
  2. 2CALCULATE and Filter Manipulation
  3. 3Iterator, Aggregation, and Lookup Functions
  4. 4Time Intelligence and Date Tables
  5. 5Data Modeling, Relationships, and Schemas
  6. 6Performance, Storage Modes, and Security

Drill it

Reading is not remembering. These come from the Power Bi Dax Fundamentals deck:

Q

What is a DAX measure?

A calculated formula created using DAX that is evaluated at query time based on filter context. Measures return dynamic values depending on the filters applied...

Q

How does filter context work in DAX?

Filter context is the set of filters applied to a calculation, generated by slicers, visuals, page-level filters, or row-level security. It determines which row...

Q

What does the CALCULATE function do?

CALCULATE evaluates an expression in a modified filter context. It can add, replace, or remove filters on specified columns, overriding the existing filter cont...

Q

What is the syntax for CALCULATE?

CALCULATE(, , , ...). The expression is evaluated after applying all listed filter arguments, which can be boolean expressions, table expressions, or KEEPFILTER...