EXPAND DAX Function (Visual calculations)

Retrieves a context with added levels of detail compared to the current context. If an expression is provided, returns its value in the new context, allowing for navigation in hierarchies and calculation at a more detailed level.

Syntax

EXPAND ( [<Expression>] [, <Axis>] [, <Column> [, <Column> [, … ] ] ] [, <N>] )
Parameter Attributes Description
Expression Optional

The expression to be evaluated in the new context.

Axis Optional

An axis reference.

Column Optional
Repeatable

A column in the data grid.

N Optional

The number of levels to expand. If omitted, the default value is 1.

Return values

Scalar A single value of any type.

The value of Expression after EXPAND moves the context down one or more levels. Without Expression, EXPAND does not return a value: it changes the context, and you can use it only as a filter argument of CALCULATE.

Notes

The visual calculation functions have an axis parameter that is defined in the VISUAL SHAPE query syntax produced by the visual calculation feature in Power BI.

Remarks

EXPAND can be used only in a visual calculation. In a measure or in a calculated column, EXPAND returns an error.

EXPAND has two forms. With Expression, EXPAND moves the context down the hierarchy and returns the value of Expression in the new context. With Expression, you must also use Axis or at least one Column, otherwise EXPAND returns an error. Without Expression, EXPAND only moves the context. You can use this form only as a filter argument of CALCULATE, for example CALCULATE ( MAX ( [Sales Amount] ), EXPAND ( ROWS ) ).

A lower level usually has more than one cell for each cell of the current level. Therefore, Expression must aggregate the values, for example with SUM, AVERAGE, MIN, MAX, or COUNT. A column reference without an aggregation, such as EXPAND ( [Sales Amount], ROWS ), returns an error.

With Axis, the levels are all the columns of that axis. N is the number of levels to move down, and the default is 1. N must be 1 or more, otherwise EXPAND returns an error. EXPAND rounds a decimal N to the nearest integer. If N is larger than the number of levels below the current cell, EXPAND stops at the lowest level of the axis.

With one or more Column arguments, EXPAND moves down to the first level that includes all the columns. If the current cell already includes the columns, EXPAND does not move. For example, with Year, Quarter, and Month on rows, EXPAND ( MAX ( [Sales Amount] ), [Month] ) returns the largest month value in a total, year, or quarter row, and the value of the current cell in a month row.

On the lowest level, EXPAND does not move and evaluates Expression in the current cell. If the visual does not have the axis (for example, COLUMNS in a visual with only rows), EXPAND does not move.

To move directly to the lowest level of an axis, use EXPANDALL. To move up the hierarchy, use COLLAPSE.

» 5 related articles

Examples

--  EXPAND moves the visual calculation down the ROWS axis.
--  The query simulates a matrix with Year, Quarter, and Month on rows.
--  Expression must aggregate the values of the lower level.
--  MaxOfChildren:      largest value one level down (N = 1 is the default)
--  MaxOfGrandchildren: largest value two levels down
--  MaxMonth:           largest value at the Month level (no move on Month)
--  AvgOfChildren:      EXPAND without expression, as a CALCULATE modifier
DEFINE
    COLUMN '__V'[MaxOfChildren] = EXPAND ( MAX ( [Sales Amount] ), ROWS )
    COLUMN '__V'[MaxOfGrandchildren] = EXPAND ( MAX ( [Sales Amount] ), ROWS, 2 )
    COLUMN '__V'[MaxMonth] = EXPAND ( MAX ( [Sales Amount] ), [Month] )
    COLUMN '__V'[AvgOfChildren] =
        CALCULATE ( AVERAGE ( [Sales Amount] ), EXPAND ( ROWS ) )
    VAR __Core =
        SUMMARIZECOLUMNS (
            ROLLUPADDISSUBTOTAL (
                'Date'[Calendar Year Number], "IsGrandTotalRowTotal",
                'Date'[Calendar Year Quarter Number], "IsYearTotal",
                'Date'[Calendar Year Month Number], "IsQuarterTotal"
            ),
            TREATAS ( { 2007, 2008 }, 'Date'[Calendar Year Number] ),
            TREATAS ( { 1, 2, 3, 4, 5, 6 }, 'Date'[Month Number] ),
            "Sales_Amount", [Sales Amount]
        )
    VAR __Input =
        SELECTCOLUMNS (
            __Core,
            "Year", 'Date'[Calendar Year Number],
            "Quarter", 'Date'[Calendar Year Quarter Number],
            "Month", 'Date'[Calendar Year Month Number],
            "IsGrandTotalRowTotal", [IsGrandTotalRowTotal],
            "IsYearTotal", [IsYearTotal],
            "IsQuarterTotal", [IsQuarterTotal],
            "Sales Amount", [Sales_Amount]
        )
    TABLE '__V' = __Input
        WITH VISUAL SHAPE
        AXIS ROWS
            GROUP [Year] TOTAL [IsGrandTotalRowTotal]
            GROUP [Quarter] TOTAL [IsYearTotal]
            GROUP [Month] TOTAL [IsQuarterTotal]
            ORDER BY [Year] ASC, [Quarter] ASC, [Month] ASC
        DENSIFY "IsDensifiedRow"
EVALUATE
SELECTCOLUMNS (
    '__V',
    "Year", [Year],
    "Quarter", [Quarter],
    "Month", [Month],
    "Sales Amount", [Sales Amount],
    "MaxOfChildren", [MaxOfChildren],
    "MaxOfGrandchildren", [MaxOfGrandchildren],
    "MaxMonth", [MaxMonth],
    "AvgOfChildren", [AvgOfChildren]
)
ORDER BY [Year], [Quarter], [Month]
Year Quarter Month Sales Amount MaxOfChildren MaxOfGrandchildren MaxMonth AvgOfChildren
(Blank) (Blank) (Blank) 10,247,701.35 5,693,275.41 3,046,602.02 1,128,104.82 5,123,850.68
2007 (Blank) (Blank) 5,693,275.41 3,046,602.02 1,128,104.82 1,128,104.82 2,846,637.70
2007 20071 (Blank) 2,646,673.39 961,289.24 961,289.24 961,289.24 882,224.46
2007 20071 200701 794,248.24 794,248.24 794,248.24 794,248.24 794,248.24
2007 20071 200702 891,135.91 891,135.91 891,135.91 891,135.91 891,135.91
2007 20071 200703 961,289.24 961,289.24 961,289.24 961,289.24 961,289.24
2007 20072 (Blank) 3,046,602.02 1,128,104.82 1,128,104.82 1,128,104.82 1,015,534.01
2007 20072 200704 1,128,104.82 1,128,104.82 1,128,104.82 1,128,104.82 1,128,104.82
2007 20072 200705 936,192.74 936,192.74 936,192.74 936,192.74 936,192.74
2007 20072 200706 982,304.46 982,304.46 982,304.46 982,304.46 982,304.46
2008 (Blank) (Blank) 4,554,425.94 2,738,040.73 999,667.17 999,667.17 2,277,212.97
2008 20081 (Blank) 1,816,385.21 656,766.69 656,766.69 656,766.69 605,461.74
2008 20081 200801 656,766.69 656,766.69 656,766.69 656,766.69 656,766.69
2008 20081 200802 600,080.00 600,080.00 600,080.00 600,080.00 600,080.00
2008 20081 200803 559,538.52 559,538.52 559,538.52 559,538.52 559,538.52
2008 20082 (Blank) 2,738,040.73 999,667.17 999,667.17 999,667.17 912,680.24
2008 20082 200804 999,667.17 999,667.17 999,667.17 999,667.17 999,667.17
2008 20082 200805 893,231.96 893,231.96 893,231.96 893,231.96 893,231.96
2008 20082 200806 845,141.60 845,141.60 845,141.60 845,141.60 845,141.60

Related articles

Learn more about EXPAND in the following articles:

Last update: Oct 29, 2026   » Contribute   » Show contributors

Contributors: Alberto Ferrari, Marco Russo

Microsoft documentation: https://learn.microsoft.com/en-us/dax/expand-function-dax

2018-2026 © 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.

Passed by Expression

This parameter is passed by expression and can be evaluated multiple times in different evaluation contexts.

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 EXPAND? 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.