Finding Maximum Values Using MAX, MAXA and MAXX in DAX
In this article, we will learn how to find maximum values in DAX using
MAX, MAXA, and MAXX.
We will also understand how MAXX can evaluate an expression
for every row and return the highest result.
📥 Practice Data:
Download Practice Data Free
🎥 Prefer learning through video?
DAX YouTube Playlist
What Are MAX, MAXA and MAXX in DAX?
DAX provides different functions for finding the largest value from data.
The three functions used in this query are MAX,
MAXA, and MAXX.
Although all three are related to finding maximum values, they work in
different ways. MAX works directly with a column,
MAXA evaluates a column while also handling logical values,
and MAXX evaluates an expression row by row before finding
the maximum result.
| Function | Purpose |
|---|---|
| MAX | Returns the largest value from a column. |
| MAXA | Returns the largest value from a column while evaluating logical values. |
| MAXX | Evaluates an expression for each row and returns the largest result. |
1. Displaying the Maximum Value Query Result
Query
EVALUATE
MaxMinTable
Step-by-step explanation
Step 1: EVALUATE
EVALUATE is used to return a table expression as the result
of a DAX query.
Step 2: MaxMinTable
MaxMinTable is the table being returned. This allows us to
inspect the source data before applying the maximum-value calculations.
What will you get?
You will see the rows and columns available in MaxMinTable.
The exact values depend on the practice data used with this query.
The first EVALUATE is useful for inspecting the source table
before applying aggregation and iterator functions.
2. Finding the Maximum Value Using MAX
Query
MAX(MaxMinTable[Column A])
Step-by-step explanation
Step 1: MAX
The MAX function returns the largest value from a column.
Step 2: MaxMinTable[Column A]
This specifies the column from which DAX should find the maximum value.
Step 3: Result
DAX evaluates the values in Column A and returns the
highest value found in that column.
ROW(
"Col A", MAX(MaxMinTable[Column A])
)
Here, ROW creates a one-row table and names the calculated
result Col A.
Use MAX when you need the largest value from a column.
3. Finding the Maximum Value Using MAXA
Query
MAXA(MaxMinTable[Column D])
Step-by-step explanation
Step 1: MAXA
MAXA returns the largest value from a column while evaluating
logical values as part of the calculation.
Step 2: MaxMinTable[Column D]
The expression specifies Column D as the column to evaluate.
Step 3: Result
DAX evaluates the values in the column and returns the maximum result.
ROW(
"Col D", MAXA(MaxMinTable[Column D])
)
The result is returned as a column named Col D in the
one-row result generated by ROW.
MAXA is useful when the column may contain logical values
that need to participate in the maximum calculation.
4. Finding the Maximum Value Using MAX
Query
MAX(MaxMinTable[Column E])
Step-by-step explanation
Step 1: Specify the column
MaxMinTable[Column E] identifies the column whose maximum
value we want to find.
Step 2: Apply MAX
MAX compares the values in Column E and
returns the largest value.
ROW(
"Col E", MAX(MaxMinTable[Column E])
)
The same MAX function can be applied to different columns
depending on the business calculation you need.
5. Finding the Maximum Calculated Result Using MAXX
Query
MAXX(
MaxMinTable,
[Column A] + [Column B]
)
Step-by-step explanation
Step 1: MAXX
MAXX is an iterator function. It evaluates an expression
for every row of a table and then returns the highest result.
Step 2: MaxMinTable
This is the table over which MAXX iterates.
Step 3: [Column A] + [Column B]
For each row, DAX adds the value from Column A to the value
from Column B.
Step 4: Find the maximum calculated value
After calculating Column A + Column B for every row,
MAXX returns the highest calculated result.
This is different from simply finding the maximum value of
Column A or Column B. Here, the maximum is
calculated from a row-level expression.
ROW(
"Max Difference",
MAXX(MaxMinTable, [Column A] + [Column B])
)
Although the output column is named Max Difference in the
query, the expression actually calculates the maximum of
Column A + Column B. It is therefore a maximum of a
row-level sum, not a difference.
6. Understanding ROW in This Query
Query
ROW(
"Col A", MAX(MaxMinTable[Column A]),
"Col D", MAXA(MaxMinTable[Column D]),
"Col E", MAX(MaxMinTable[Column E]),
"Max Difference", MAXX(MaxMinTable, [Column A] + [Column B])
)
Step-by-step explanation
Step 1: ROW
ROW creates a single-row table containing the expressions
and names supplied to it.
Step 2: “Col A”
The first output column contains the maximum value from
MaxMinTable[Column A].
Step 3: “Col D”
The second output column contains the maximum result from
MAXA(MaxMinTable[Column D]).
Step 4: “Col E”
The third output column contains the maximum value from
MaxMinTable[Column E].
Step 5: “Max Difference”
The fourth output column contains the maximum row-level result produced by
adding Column A and Column B for every row.
Result structure
| Col A | Col D | Col E | Max Difference |
|---|---|---|---|
| Maximum of Column A | Maximum of Column D using MAXA | Maximum of Column E | Maximum of Column A + Column B per row |
The actual numeric values depend on the data stored in
MaxMinTable.
MAX vs MAXA vs MAXX
| Function | Input | How It Works | Example |
|---|---|---|---|
| MAX | Column | Finds the largest value in the column. | MAX(MaxMinTable[Column A]) |
| MAXA | Column | Finds the largest value while evaluating logical values. | MAXA(MaxMinTable[Column D]) |
| MAXX | Table + Expression | Evaluates the expression for every row and returns the largest result. | MAXX(MaxMinTable, [Column A] + [Column B]) |
Important Notes
1. MAX works directly with a column
When you already have the column containing the values you want to compare,
MAX provides a direct way to return the largest value.
2. MAXA is different from MAX
MAXA is designed to evaluate logical values as part of its
calculation. This makes it different from the standard numeric
MAX function.
3. MAXX evaluates an expression row by row
MAXX is especially useful when the value you want to
maximize does not already exist as a column. You can create the value
through an expression for each row.
4. The table argument comes first in MAXX
MAXX(
<Table>,
<Expression>
)
The first argument defines the table to iterate over, while the second
argument defines the expression to evaluate for each row.
5. ROW creates the final single-row result
In this query, ROW combines multiple calculated results
into a single-row table, making it convenient to display several maximum
calculations together.
📝 Practice Exercise
Using the MaxMinTable, try creating a DAX query that
returns the following results in one row:
- Maximum value of Column A
- Maximum value of Column B
- Maximum value of Column C
- Maximum of Column A + Column B for every row
Use ROW, MAX, and
MAXX to build the query.
Expected Query Pattern
EVALUATE
ROW(
"Max A", MAX(MaxMinTable[Column A]),
"Max B", MAX(MaxMinTable[Column B]),
"Max C", MAX(MaxMinTable[Column C]),
"Max A + B", MAXX(
MaxMinTable,
[Column A] + [Column B]
)
)
Conclusion
In this article, we learned how to find maximum values using
MAX, MAXA, and MAXX
in a DAX query.
- MAX returns the largest value from a column.
- MAXA evaluates a column while handling logical values in the calculation.
- MAXX evaluates an expression for every row and returns the highest result.
- ROW can combine multiple calculations into a single-row table.
- MAXX is particularly useful when the value to maximize is created from a row-level expression.
Understanding the difference between MAX and
MAXX is especially important when writing advanced DAX
queries, because MAXX allows you to calculate a value
first and then find the maximum across those calculated results.
📥 Practice Data:
Download Practice Data Free
🎥 Prefer learning through video?
DAX YouTube Playlist