What is the difference between Distinct() and Values() in DAX
Loading
What is the difference between Distinct() and Values() in DAX
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Jaish MathewsPosted Jan 1, 2025, 3:01 PM
In DAX (Data Analysis Expressions),
1. DISTINCT()DISTINCT()andVALUES()are two functions that seem similar at first glance but have key differences in behavior and use cases.-
-
- Removes duplicates from the specified column or table expression.
- Always returns a table with the distinct values, regardless of the current filter context.
-
- To calculate unique values in a dataset.
- Useful in aggregation and when filtering operations need to consider distinct values.
-
2. VALUES()Purpose: Returns a one-column table that contains the unique values from a specified column or expression.
Behavior:
Typical Use Cases:
Example:
This returns a table of all unique products in the
Salestable.-
-
- If there is a filter applied to the column,
- If no filter is applied, it behaves similarly to
- If all rows in the column are blank, it returns an empty table.
- If the entire column is filtered out, it returns a blank value (different from
-
- To retrieve values affected by the filter context.
- Often used in relationship calculations, measures, or scenarios where filter context sensitivity is required.
-
Key DifferencesPurpose: Returns a one-column table of unique values for a column, but it respects the current filter context.
Behavior:
VALUES()returns only the unique values visible under that filter.DISTINCT().DISTINCT).Typical Use Cases:
Example:
This returns the unique regions in the
Salestable, but only those visible in the current filter context.DISTINCT()when you want the global unique values, regardless of any filters in place.VALUES()when you need to work within the current filter context and account for filters applied to the data.Rajeesh MenothPosted Jan 1, 2025, 5:46 AM
Hi Kiran,
As per the microsoft docs :
The DISTINCT function allows a column name or any valid table expression to be its argument but the VALUES function only accepts a column name or a table name as the argument.
Reference :
https://learn.microsoft.com/en-us/dax/values-function-dax