Forum Discussion
CALCULATE with ALL(table[column])
- 8 years ago
Just reproduced this. I am getting 6. Do you have another filter on there somewhere?
- 8 years ago
Hi both,
Thanks for your feedback.
The table was actually loaded from a SQL DB. It turns out that the duplicating the query and running the measure on it, is giving the correct result. So I now have two identical tables in my PBIX, giving different measure results !
I will check with MS if a bug needs to be reported.
Hi,
I've done some more digging on this, and finally found the culprit: Sort by Column.
When there is no sort order in the model, then I get the expected result, However, I had a "RegionSortOrder" column set in the "sort by column" on "Region". The "#CustomersAcrossRegions" measure only cancels the "Region" filtering, which is leading to the unexpected result as shown above. The fix is to add "RegionSortOrder" in my measure:
#CustomersAcrossRegions = CALCULATE(DISTINCTCOUNT(table[CustomerID]), ALL(table[Region]), ALL(table[RegionSortOrder]))
While I can understand how it works behind the scenes in the DAX query, I would consider it a misleading side effect, rather than the expected behavior: why should I care about a dimension's sort order in my measure ?