Class(Age, 10)
Class (bucketing into bins) in Power BI
Qlik's Class() puts a number into a fixed-width bin and returns a dual: a label such as 20<=x<30 plus the lower bound as the number. Power BI has no single function for this. Build a bin column with FLOOR (or Number.RoundDown) plus a label and a sort-by column, or use the built-in Groups and bins feature.
What it does in Qlik
Class(expression, interval [, label [, offset]]) returns a dual value. The text is a<=x<b, and the number is the lower bound a. label replaces the x in the text, and offset moves the starting point of the bins. For example, Class(23, 10) returns 20<=x<30, and Class(23, 10, 'x', 5) returns 15<=x<25.
Qlik example
// script
Class(Age, 10, 'age') AS AgeBand
// chart (calculated dimension)
=Class(Aggr(Sum(Sales), Customer), 1000)Power BI equivalent
Calculated columns (DAX)
Age band start = INT ( Customer[Age] / 10 ) * 10 -- INT rounds down, also for negatives
Age band =
VAR lo = INT ( Customer[Age] / 10 ) * 10
RETURN FORMAT ( lo, "0" ) & "<=age<" & FORMAT ( lo + 10, "0" )Select Age band and use Sort by column > Age band start. Otherwise "100<=age<110" sorts before "20<=age<30".
Power Query
= Table.AddColumn(Source, "AgeBandStart",
each Number.RoundDown([Age] / 10) * 10, Int64.Type)Groups and bins (no code)
In Power BI Desktop, right-click a numeric or date column and choose New group, then set Group type to Bin and pick a bin size. This creates a bin column whose value is the lower bound. It covers the plain Class(x, n) case.
Bucketing a measure, the Class(Aggr()) case
// Disconnected table 'Sales band' with columns [Start] and [End]
Customers in band =
VAR lo = SELECTEDVALUE ( 'Sales band'[Start] )
VAR hi = SELECTEDVALUE ( 'Sales band'[End] )
RETURN
COUNTROWS (
FILTER (
VALUES ( Customer[CustomerID] ),
VAR s = [Sales]
RETURN NOT ISBLANK ( s ) && s >= lo && s < hi -- Aggr skips customers with no sales
)
)Without the NOT ISBLANK test, customers with no sales in the current selection would count in the band that contains 0. Calculated columns cannot react to slicers. A dynamic Class(Aggr(...)) dimension needs a disconnected band table plus a measure like this one, sometimes called dynamic segmentation.
Gotchas and behaviour differences
- Qlik's result is a dual, so it sorts by number automatically. In Power BI the label is plain text: always add a numeric sort-by column.
- Negative values: Class puts -3 in the
-10<=x<0band.INT(-3 / 10) * 10gives -10, which matches, becauseINTrounds down.TRUNCrounds toward zero and would give 0. Don't useFLOOR(x, 10)here: DAXFLOORreturns an error when the number and the significance have different signs. - Bins from Groups and bins are calculated columns, refreshed with the model, so they ignore slicers just like DAX columns.
Official documentation
- class - script and chart function (Qlik Help)
- FLOOR function (DAX) (Microsoft Learn)
- Use grouping and binning in Power BI Desktop (Microsoft Learn)
- Number.RoundDown (Power Query M) (Microsoft Learn)
Related pages
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
If(cond, then, else)
If and nested If
Qlik's If() maps directly to DAX IF and to Power Query's if ... then ... else. Long nested Ifs are cleaner as SWITCH(TRUE(), ...). Qlik's numeric booleans (-1/0) are the main difference.
Direct equivalent
Dual('Jan', 1)
Dual values
Qlik fields can hold a dual value: a text and a number at the same time. Power BI columns have one data type, so you use a text column sorted by a number column (Sort by column).
Partial / different approach
Round(Sales, 0.01)
Round, Floor and Ceil
Qlik's Round(x, step, offset) rounds to a multiple of a step such as 0.01 or 5, not to a number of decimal places. DAX ROUND takes digits and MROUND takes a multiple. Watch the tie-breaking: Qlik rounds halves up. DAX ROUND rounds away from zero. Power Query Number.Round uses banker's rounding (round half to even) by default.
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.