MAXX DAX Function (Aggregation)

Returns the largest value that results from evaluating an expression for each row of a table. Strings are compared according to alphabetical order.

Syntax

MAXX ( <Table>, <Expression> [, <Variant>] )
Parameter Attributes Description
Table
Iterator

The table containing the rows for which the expression will be evaluated.

Expression
Row Context

The expression to be evaluated for each row of the table.

Variant Optional

If true, maximum value in col will be same as order by variant desc column. Default is false.

Return values

Scalar A single value of any type.

Largest value found in the expression.

» 3 related articles
» 2 related functions

Examples

--  MAX is the short version of MAXX, when used with one column only
DEFINE
    MEASURE Sales[MAX Net Price 1] = MAX ( Sales[Net Price] )
    MEASURE Sales[MAX Net Price 2] = MAXX ( Sales, Sales[Net Price] )
    MEASURE Sales[MAX Line Amount] = 
        MAXX ( Sales, Sales[Quantity] * Sales[Net Price] )
EVALUATE
SUMMARIZECOLUMNS (
    'Product'[Color],
    "MAX Net Price 1", [MAX Net Price 1],
    "MAX Net Price 2", [MAX Net Price 2],
    "MAX Line Amount", [MAX Line Amount]
)
Color MAX Net Price 1 MAX Net Price 2 MAX Line Amount
Silver 2,879.99 2,879.99 9,996.00
Blue 3,199.99 3,199.99 12,799.96
White 3,199.99 3,199.99 12,799.96
Red 1,989.00 1,989.00 7,956.00
Black 2,499.00 2,499.00 9,996.00
Green 3,199.99 3,199.99 10,239.97
Orange 2,879.99 2,879.99 8,639.97
Pink 1,989.00 1,989.00 7,956.00
Yellow 789.75 789.75 2,369.25
Purple 104.89 104.89 419.56
Brown 3,199.99 3,199.99 12,799.96
Grey 3,199.99 3,199.99 12,799.96
Gold 605.70 605.70 2,356.00
Azure 290.00 290.00 1,160.00
Silver Grey 673.00 673.00 2,692.00
Transparent 2.94 2.94 11.76
--  MAXX is needed to iterate the content of a variable,
--  indeed MAX works only with columns in the model
DEFINE
    MEASURE Sales[Sales Amount] =
        SUMX ( Sales, Sales[Quantity] * Sales[Net Price] )
    MEASURE Sales[MAX Monthly Sales] =
        VAR MonthlySales =
            ADDCOLUMNS (
                DISTINCT ( 'Date'[Calendar Year Month] ),
                "@MonthlySales", [Sales Amount]
            )
        VAR FilteredSales =
            FILTER ( MonthlySales, [@MonthlySales] > 10000 )
        VAR Result =
            -- Iterator required to aggregate the @MonthlySales column        
            MAXX ( FilteredSales, [@MonthlySales] )
        RETURN
            Result
EVALUATE
SUMMARIZECOLUMNS ( 
    'Product'[Color], 
    "MAX Monthly Sales", [MAX Monthly Sales] 
)
Color MAX Monthly Sales
Silver 355,007.95
Blue 161,351.67
White 333,756.67
Red 77,069.70
Black 293,091.79
Green 93,839.92
Orange 69,139.50
Pink 86,940.06
Grey 169,268.89
Silver Grey 31,808.00
Brown 101,388.85
Gold 20,951.00
Yellow 13,791.93

Related articles

Learn more about MAXX in the following articles:

Related functions

Other related functions are:

Last update: Nov 14, 2024   » Contribute   » Show contributors

Contributors: Alberto Ferrari, Marco Russo

Microsoft documentation: https://docs.microsoft.com/en-us/dax/maxx-function-dax

2018-2024 © SQLBI. All rights are reserved. Information coming from Microsoft documentation is property of Microsoft Corp. » Contact us   » Privacy Policy & Cookies

Context Transition

This function performs a Context Transition if called in a Row Context. Click to read more.

Row Context

This expression is executed in a Row Context. Click to read more.

Iterator

Not recommended

The use of this function is not recommended. See Remarks and Related functions for alternatives.

Not recommended

The use of this parameter is not recommended.

Deprecated

This function is deprecated. Jump to the Alternatives section to see the function to use.

Volatile

A volatile function may return a different result every time you call it, even if you provide the same arguments. Click to read more.

Deprecated

This parameter is deprecated and its use is not recommended.

DirectQuery compatibility

Limitations are placed on DAX expressions allowed in measures and calculated columns.
The state below shows the DirectQuery compatibility of the DAX function.

Contribute

Want to improve the content of MAXX? Did you find any issue?
Please, report it us! All submissions will be evaluated for possible updates of the content.


This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.