MAXX
The largest value of an expression over a table's rows; with TRUE as a third argument, text and numbers compare as ORDER BY sorts them.
Group: Aggregation. Compatible with DAX.
Syntax
MAXX ( <table>, <expression> [, <variant>] )
| Parameter | Type | Description |
|---|---|---|
table | Table | The rows to go through. |
expression | Expression evaluated for each row | The value worked out for each row: a number, a date or text. |
variant | Boolean optional | TRUE to allow results of different types, numbers and texts, compared in the order a sort puts them; FALSE or left out to keep to one type. |
Returns
Same type as its results. The largest of the expression's results, blanks left out.
Remarks
- Over an empty table, or when every result is blank, the answer is BLANK.
- Text is compared without regard to case.
MAXX ( VALUES ( Products[Product] ), [Revenue] )is the revenue of the best-selling product; to know which product that is, useTOPN.
Examples
The largest order line
EVALUATE
VAR Orders =
DATATABLE (
"Product", STRING, "Liters", INTEGER, "Price", DOUBLE,
{ { "Pils", 120, 38 }, { "IPA", 80, 64 }, { "Cider", BLANK (), 52 }, { "Stout", 45, 70 } }
)
RETURN
ROW ( "Largest line", MAXX ( Orders, [Liters] * [Price] ) )
| Largest line |
|---|
| 5120 |
The best product's revenue
EVALUATE
ROW ( "Best revenue", MAXX ( VALUES ( Products[Product] ), [Revenue] ) )
| Best revenue |
|---|
| 38164388 |