EXPANDALL
In a visual calculation, an expression evaluated at the bottom level of an axis.
A visual calculation works on the table behind a visual: a row for each group on the visual's axes and one for each of their totals. To try one in the OAX view, give a table that shape with DEFINE TABLE ... WITH VISUAL SHAPE: its axes, their groups, the TRUE/FALSE column that marks each group's totals and the order, and with DENSIFY a name for the column that marks rows the shape fills in. Then write the calculation as a COLUMN of that table, as Power BI's own queries do. The examples below are queries of that kind, small enough to check by hand.
Group: Window and visual calculations. Compatible with DAX.
Syntax
EXPANDALL ( <expression>, <axis> )
EXPANDALL ( <axis> )
| Parameter | Type | Description |
|---|---|---|
expression | Expression | What is worked out over the bottom-level rows under the current one; usually an aggregation. Left out, EXPANDALL is a filter of CALCULATE. |
axis | Axis | The axis to go down: ROWS, COLUMNS, or several of them. |
Returns
Same type as the expression. The expression's value over the lowest-level rows under the current row.
Remarks
- On the grand total,
EXPANDALL ( AVERAGE ( [Liters] ), ROWS )averages every quarter, whereEXPANDwould average the years. - A field alone over several rows is an error: aggregate it.
- It works only in a visual calculation; in a measure, a calculated column or a plain query it is an error.
Examples
Average of the bottom level against average of the children
On the grand total the two differ: four quarters average 125, two years 250.
DEFINE
TABLE Visual =
DATATABLE (
"Year", INTEGER, "Quarter", INTEGER, "Liters", INTEGER, "All years", BOOLEAN, "All quarters", BOOLEAN,
{
{ 2025, 1, 100, FALSE, FALSE }, { 2025, 2, 120, FALSE, FALSE }, { 2025, BLANK (), 220, FALSE, TRUE },
{ 2026, 1, 130, FALSE, FALSE }, { 2026, 2, 150, FALSE, FALSE }, { 2026, BLANK (), 280, FALSE, TRUE },
{ BLANK (), BLANK (), 500, TRUE, TRUE }
}
)
WITH VISUAL SHAPE
AXIS ROWS
GROUP [Year] TOTAL [All years]
GROUP [Quarter] TOTAL [All quarters]
ORDER BY [Year], [Quarter]
DENSIFY "Added"
COLUMN Visual[Of the quarters] = EXPANDALL ( AVERAGE ( [Liters] ), ROWS )
COLUMN Visual[Of the children] = EXPAND ( AVERAGE ( [Liters] ), ROWS )
EVALUATE
SELECTCOLUMNS (
Visual,
"Year", [Year], "Quarter", [Quarter], "Liters", [Liters],
"Of the quarters", [Of the quarters],
"Of the children", [Of the children]
)
ORDER BY ISBLANK ( [Year] ), [Year], ISBLANK ( [Quarter] ), [Quarter]
| Year | Quarter | Liters | Of the quarters | Of the children |
|---|---|---|---|---|
| 2025 | 1 | 100 | 100 | 100 |
| 2025 | 2 | 120 | 120 | 120 |
| 2025 | (blank) | 220 | 110 | 110 |
| 2026 | 1 | 130 | 130 | 130 |
| 2026 | 2 | 150 | 150 | 150 |
| 2026 | (blank) | 280 | 140 | 140 |
| (blank) | (blank) | 500 | 125 | 250 |