Count(DISTINCT CustomerID)
Count, Count(DISTINCT) and counting key fields in Power BI
Count(DISTINCT Field) maps to DISTINCTCOUNT. Watch out for blanks, for which table you count from, and for the Qlik habit of counting key fields.
Short answer: Count(DISTINCT CustomerID) becomes DISTINCTCOUNT(Sales[CustomerKey]) for customers with sales, or COUNTROWS(Customer) for customers in the filter. DISTINCTCOUNT counts BLANK as a value; DISTINCTCOUNTNOBLANK does not.
What it does in Qlik
Count(Field) counts non-null values over the records in the selection. Count(DISTINCT Field) counts the unique values. Qlik never counts null values. When the field is a key shared by two tables, it is ambiguous which table you are counting, and counting key fields is a well-known Qlik pitfall.
Qlik example
Count(DISTINCT CustomerID) // unique customers
Count(OrderID) // non-null OrderID values on the records
Count({<Year={2024}>} DISTINCT CustomerID)Power BI equivalent
DAX measures
Customers with sales = DISTINCTCOUNT ( Sales[CustomerKey] )
Customers (dimension) = COUNTROWS ( Customer )
Order lines = COUNTROWS ( Sales )
Customers 2024 =
CALCULATE ( DISTINCTCOUNTNOBLANK ( Sales[CustomerKey] ), 'Date'[Year] = 2024 )Gotchas and behaviour differences
DISTINCTCOUNTcounts a BLANK as one extra value. Qlik'sCount(DISTINCT ...)never counts null. UseDISTINCTCOUNTNOBLANKwhen blanks are possible.COUNT(column)in DAX also skips blanks.COUNTROWS(table)counts every row, which is usually whatCount(OrderID)meant.- Decide which table answers the question. A Product slicer filters
Salesbut notCustomer(with single-direction relationships), soCOUNTROWS(Customer)would ignore it. - Distinct counts are not additive. A matrix total is the distinct count over all rows, not the sum of the rows. Qlik behaves the same way.
Official documentation
- Count - chart function (Qlik Help)
- DISTINCTCOUNT function (DAX) (Microsoft Learn)
- DISTINCTCOUNTNOBLANK function (DAX) (Microsoft Learn)
- DISTINCTCOUNT (dax.guide)
Related pages
Null(), IsNull(), NullAsValue
NULL handling vs DAX BLANK and M null
Qlik NULL, DAX BLANK and Power Query null follow different arithmetic and comparison rules. This is one of the most common reasons migrated numbers do not reconcile.
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
Only(Region)
Only
Only() returns a value when exactly one value is possible and null otherwise. In DAX that is SELECTEDVALUE, which also accepts an alternate result.
Direct equivalent
$Syn tables (automatic)
Synthetic keys and associative linking
Qlik links tables automatically on every field with the same name and builds synthetic keys when they share several fields. Power BI never links by name. Relationships are explicit, use a single column and have a direction, so migrations usually remodel to a star schema.
No 1:1 equivalent
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.