A DAX question!
Almost correct, but not quite 😉
Here's the breakdown:
DISTINCTCOUNT: This is the correct function to count the number of unique values in a column. Well done!
'INCREASED_february'[NRD No.]: This is the correct column reference. You've properly qualified the column name with the table name ('INCREASED_february') and used the correct syntax ([NRD No.] with square brackets and a space in the column name).
all(: This is the problematic part. The ALL function is used to remove filters from a table or column, but you've used it incorrectly here.
ALL should be used like this: ALL('TableName') or ALL('TableName'[ColumnName]). Notice the single quotes around the table name, and no parentheses around the column name.
In your formula, you've got all( which is incomplete and will throw a syntax error.
Here's the corrected measure:
Total Increased agents = DISTINCTCOUNT(ALL('INCREASED_february'[NRD No.]))
By wrapping the column reference in ALL, you're telling DAX to:
- Remove any filters applied to the
'INCREASED_february'[NRD No.] column.
- Count the distinct values in that column, ignoring any filters.
However, if your intention is to simply count the distinct NRD No. values in the entire 'INCREASED_february' table, without removing any filters, you can simplify the measure to:
Total Increased agents = DISTINCTCOUNT('INCREASED_february'[NRD No.])
In this case, ALL is not needed, as you're not trying to override any filters.
So, to summarize:
- If you want to ignore all filters on the column and count distinct values: Use
ALL like I showed above.
- If you want to respect existing filters and simply count distinct values: Remove
ALL altogether.
Choose the one that fits your requirements! 😊
Example use cases:
Scenario 1: Ignore all filters
You have a report with a slicer filtering by region. You want the measure to always count distinct NRD No. values across all regions, disregarding the slicer selection. Use ALL.
Scenario 2: Respect existing filters
You have the same report, but now you want the measure to count distinct NRD No. values only for the selected region(s). Remove ALL.
Hope this clears up any confusion! Let me know if you have further questions.