Applies to: Calculated column
Calculated table
Measure
Visual calculation
Returns the unique ranking for the current context within the specified partition, sorted by the specified order. If a match cannot be found then then rownumber is blank.
ROWNUMBER ( [ or ][, ][, ][, ][, ][, ] )
The rownumber number for the current context.
Each , , and column must have a corresponding outer value to help define the current row on which to operate, with the following behavior:
If is present, then ROWNUMBER will try to use columns in and to idenfity the current row.
If the columns specified within and cannot uniquely identify every row in , then:
can be used in visual calculations only, and cannot be used in combination with or . If is present, can be specified but cannot.
The following DAX query:
EVALUATE ADDCOLUMNS( 'DimGeography', "UniqueRank", ROWNUMBER( 'DimGeography', ORDERBY( 'DimGeography'[StateProvinceName], desc, 'DimGeography'[City], asc), PARTITIONBY( 'DimGeography'[EnglishCountryRegionName]))) ORDER BY [EnglishCountryRegionName] asc, [StateProvinceName] desc, [City] asc
Returns a table that uniquely ranks each geography with the same EnglishCountryRegionName, by their StateProvinceName and City.
The following visual calculation DAX queries:
SalesRankWithinYear = ROWNUMBER(ORDERBY([SalesAmount], DESC), PARTITIONBY([CalendarYear])) SalesRankAllHistory = ROWNUMBER(ORDERBY([SalesAmount], DESC))
Create two columns that uniquely rank each month by the total sales, both within each year, and the entire history.
The screenshot below shows the visual matrix and the first visual calculation expression: