Rank(Sum(Sales))
Rank in Power BI
Qlik's Rank() ranks rows within the current column segment and has its own tie modes and a text format ("3 - 4"). In DAX, use RANKX or the newer RANK window function. Pick the ties option deliberately.
What it does in Qlik
Rank([TOTAL] expr [, mode [, fmt]]) ranks the current row against the others in the column segment, which is all rows with the same outer dimension values. The highest value gets rank 1. For ties, mode sets the number (lowest, average, highest, or sequential with mode 4) and fmt sets the text (default "low - high").
Qlik example
Rank(Sum(Sales)) // default mode 0, fmt 0
Rank(Sum(Sales), 1, 1) // ties share the lowest rank, shown as one number
Rank(TOTAL Sum(Sales)) // across the whole column, ignoring the outer dimensionPower BI equivalent
RANKX (classic)
Sales rank =
IF (
HASONEVALUE ( Product[Name] ),
RANKX ( ALLSELECTED ( Product[Name] ), [Sales], , DESC, SKIP )
)RANK window function
Sales rank (window) =
RANK ( DENSE, ALLSELECTED ( Product[Name] ), ORDERBY ( [Sales], DESC ) )In a matrix by Category > Product, ALLSELECTED(Product[Name]) keeps the row's Category filter, so ranks restart per category. That is Qlik's column segment. Add ALLSELECTED(Product[Category]) to rank across all categories, like Rank(TOTAL ...).
Gotchas and behaviour differences
- Ties: Qlik mode 1 (lowest rank on all tied rows) is
SKIP. Qlik mode 4 (sequential numbering) is closer toROWNUMBER. Mode 0 and the default "3 - 4" text have no DAX equivalent. - Without the
HASONEVALUEguard,RANKXreturns 1 on total rows. - Products with no sales are still in
ALLSELECTED(Product[Name])and get the last rank. Qlik does not show rows with zero values by default.
Official documentation
- Rank - chart function (Qlik Help)
- RANKX function (DAX) (Microsoft Learn)
- RANK function (DAX) (Microsoft Learn)
- RANKX (dax.guide)
Related pages
Sum(TOTAL Sales) / Sum(TOTAL <Category> Sales)
The TOTAL qualifier
Qlik's TOTAL qualifier makes an aggregation ignore the chart dimensions but keep the selections. In DAX that is ALLSELECTED. TOTAL <Field> keeps one dimension, which maps to removing only the other dimension columns.
Direct equivalent
FirstSortedValue(Product, -Aggr(Sum(Sales), Product))
FirstSortedValue
FirstSortedValue returns the value of one field on the record with the lowest (or, with a minus sign, highest) sort weight, such as the top-selling product or the latest status. In DAX, use TOPN plus a tie check, or LASTNONBLANKVALUE for "latest".
Partial / different approach
RecNo(), RowNo()
RecNo and RowNo
RecNo numbers input records and RowNo numbers output rows. In Power Query, add an index column before the filter step (RecNo) or after it (RowNo). The model has no row order, so keep the index as a column.
Partial / different approach
Avg(Aggr(Sum(Sales), Customer))
Aggr (nested aggregation)
Aggr builds a virtual table of aggregated values, for example sales per customer, so you can aggregate again. In DAX that is an iterator (AVERAGEX, MAXX, COUNTROWS(FILTER(...))) over VALUES or SUMMARIZE that calls a measure.
Partial / different approach
Spotted an error or a better pattern? QlikToDax is maintained by a working BI consultant; corrections are welcome via the About page. Last reviewed 2026-10-25.