Short answer: both return the distinct values of a column visible in the current filter context. The difference is the blank row: when a fact table has keys that do not exist in a dimension, the dimension gets a virtual blank row, and VALUES includes it while DISTINCT does not. VALUES also accepts a table name (all its visible rows plus the blank row), and DISTINCT accepts any table expression. In a model with clean keys they return the same thing.
The difference shows up as a mysterious (Blank) item in slicers and visuals, and as a count that is one higher than expected.
When do they differ?
| Expression | Returns | Rows |
|---|---|---|
| VALUES ( 'Product'[Product] ) | Bike, Helmet, Bottle, (Blank) | 4 |
| DISTINCT ( 'Product'[Product] ) | Bike, Helmet, Bottle | 3 |
| COUNTROWS ( VALUES ( 'Product'[Product] ) ) | 4 | |
| DISTINCTCOUNT ( 'Product'[Product] ) | 4 | |
| DISTINCTCOUNTNOBLANK ( 'Product'[Product] ) | 3 |
The sales with key 9 show up under (Blank) in every visual by product. The blank row only exists when there is a relationship violation (or when a column contains real blanks).
How do you find the keys behind (Blank)?
EVALUATE
EXCEPT ( VALUES ( Sales[Product Key] ), VALUES ( 'Product'[Product Key] ) )
-- or as a measure
Sales without Product =
CALCULATE ( [Revenue], ISBLANK ( 'Product'[Product Key] ) )Fix the source: add the missing products, or map unknown keys to an "Unknown" product row. Hiding the blank row hides missing revenue.
How are VALUES and DISTINCT used in measures?
-- iterate the visible customers
Avg Revenue per Customer = AVERAGEX ( VALUES ( Customer[Customer] ), [Revenue] )
-- the single selected value (or an error with several)
Selected Year Old = VALUES ( 'Date'[Year] )
-- better
Selected Year = SELECTEDVALUE ( 'Date'[Year] )
-- check membership
Is Bikes = "Bikes" IN VALUES ( 'Product'[Category] )A one-column, one-row table can be used as a scalar, which is why VALUES ( 'Date'[Year] ) works when exactly one year is selected and errors when several are ("A table of multiple values was supplied where a single value was expected"). Microsoft's guidance is to use SELECTEDVALUE instead.
What is FILTERS?
FILTERS ( column ) returns the values directly filtered on a column, while VALUES returns the values visible, also through filters on other columns or tables. With a slicer on Category = Bikes, VALUES ( 'Product'[Product] ) returns the bike products, but FILTERS ( 'Product'[Product] ) returns all products, because Product itself has no direct filter.
Which to use?
| Need | Use |
|---|---|
| iterate or count visible values, including unknown keys | VALUES |
| distinct values without the blank row | DISTINCT |
| distinct rows of a table expression | DISTINCT ( table expression ) |
| the one selected value | SELECTEDVALUE |
| only directly filtered values | FILTERS |
What goes wrong?
- A count that is one too high. The blank row; check referential integrity.
- VALUES as a scalar. Errors with several values; use
SELECTEDVALUE. - VALUES ( table ) in iterators. Iterates whole rows plus a possible blank row; iterate a column unless you need the row.
Where can you check this?
- Microsoft Learn: VALUES function (DAX)
- Microsoft Learn: DISTINCT function (DAX) for a column
- Microsoft Learn: FILTERS function (DAX)
Where do you start?
Run the EXCEPT query above for each fact-to-dimension relationship in DAX query view; every key it returns is a (Blank) in your reports. TREATAS uses VALUES to pass filters between tables.