PARTITIONBY
In a window function, the columns that split its table into partitions.
Group: Window and visual calculations. Compatible with DAX.
Syntax
PARTITIONBY ( <partitionBy_columnName> [, <partitionBy_columnName>] … )
| Parameter | Type | Description |
|---|---|---|
partitionBy_columnName | Column repeatable | A column of the relation; rows with the same values in these columns form one partition. |
Returns
None. It gives no value of its own: it tells the window function around it how to split the rows.
Remarks
- The window function works inside the current row's partition:
OFFSET ( -1, ... )never reaches into another product's months,RANKstarts at 1 in each category. - The columns must be columns of the relation, not new columns a table function added.
- It goes only inside a window function; anywhere else it is an error.
- In a visual calculation the reset parameter usually does this job by the visual's own levels; the two can't be given together.
Examples
Rank within each category
EVALUATE
ADDCOLUMNS (
VALUES ( Products[Product] ),
"Category", CALCULATE ( SELECTEDVALUE ( Products[Category] ) ),
"Rank in category",
RANK (
DENSE,
ALL ( Products[Product], Products[Category] ),
ORDERBY ( [Liters sold], DESC ),
PARTITIONBY ( Products[Category] )
)
)
ORDER BY [Category], [Rank in category]
| Products[Product] | Category | Rank in category |
|---|---|---|
| Pils | Beer | 1 |
| IPA | Beer | 2 |
| Lettøl | Beer | 3 |
| Cider | Cider | 1 |
The month before, in each shop
EVALUATE
VAR Pils =
FILTER (
Sales,
Sales[Product] = "Pils"
&& ( Sales[Shop] = "Shop Kampen" || Sales[Shop] = "Shop Sagene" )
&& YEAR ( Sales[Month] ) = 2026 && MONTH ( Sales[Month] ) <= 3
)
RETURN
ADDCOLUMNS (
Pils,
"Month before",
MAXX (
OFFSET ( -1, Pils, ORDERBY ( Sales[Month] ), PARTITIONBY ( Sales[Shop] ) ),
Sales[Liters]
)
)
ORDER BY Sales[Shop], Sales[Month]
| Sales[Month] | Sales[Shop] | Sales[Product] | Sales[Liters] | Month before |
|---|---|---|---|---|
| 2026-01-01 | Shop Kampen | Pils | 278 | (blank) |
| 2026-02-01 | Shop Kampen | Pils | 326 | 278 |
| 2026-03-01 | Shop Kampen | Pils | 278 | 326 |
| 2026-01-01 | Shop Sagene | Pils | 260 | (blank) |
| 2026-02-01 | Shop Sagene | Pils | 275 | 260 |
| 2026-03-01 | Shop Sagene | Pils | 262 | 275 |