cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
huguest Member
Member

DAX Measure - CALCULATE DISTINCTCOUNT with ALL not working as intended

I have a table that contains 2 types of records (Audits and Observations).  I am trying to use a measure to count the total number of Audits records.

 

DistinctCountAudit_All_Categories = CALCULATE(DISTINCTCOUNT('Audits_and_Obs'[ID]),'Audits_and_Obs'[Type]="Audit",ALL('Audits_and_Obs'[Category]))
 
I am adding the ALL('Audits_and_Obs'[Category]) to exclude a Visual Level filter that selects a Category that applies to the Observation records only, but it is not working as intended.
 
As an example, I know that I have 100 audits for a given month.  If I select one of the Categories for the Observations, the number of audit drops to 30.  I want that count to remain at 100 regardless of the Category selected. 
 
Any idea what I might be doing wrong?

 

 

9 REPLIES 9
Super User
Super User

Re: DAX Measure - CALCULATE DISTINCTCOUNT with ALL not working as intended

Hi @huguest

Can you share the pbix? It'd be much easier to see what is going on.

huguest Member
Member

Re: DAX Measure - CALCULATE DISTINCTCOUNT with ALL not working as intended

I wish I could but unfortunately, because of confidentiality issues, I cannot share the file 😞
Super User
Super User

Re: DAX Measure - CALCULATE DISTINCTCOUNT with ALL not working as intended

@huguest

OK, that's going to be hard then.

Is the visual level filter on 'Audits_and_Obs'[Category] as well? Or perhaps a [Category] from another table?

huguest Member
Member

Re: DAX Measure - CALCULATE DISTINCTCOUNT with ALL not working as intended

It is on ‘Audits_and_Obs'[Category]. What I find to be strange is that when I select a Category in the filter, the measure value changes but I have no idea based on what. None of the audit rows have a value in the Categiry column, so I have no idea what records it is counting. If I exclude the “ALL” portion of the measure, it returns 0 if I select a Category.
Super User
Super User

Re: DAX Measure - CALCULATE DISTINCTCOUNT with ALL not working as intended

@huguest

It's tough to guess what might be going on like this.Could you maybe share a simple pbix with dummy data, to avoid the confidentiality issues, that reproduces the problem?  Not sure if that will be worth your while.

 

v-yulgu-msft Super Contributor
Super Contributor

Re: DAX Measure - CALCULATE DISTINCTCOUNT with ALL not working as intended

Hi @huguest,

 

How about:

DistinctCountAudit_All_Categories = CALCULATE(DISTINCTCOUNT('Audits_and_Obs'[ID]),'Audits_and_Obs'[Type]="Audit",ALL('Audits_and_Obs'))

Best regards,

Yuliana Gu

Community Support Team _ Yuliana Gu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
huguest Member
Member

Re: DAX Measure - CALCULATE DISTINCTCOUNT with ALL not working as intended

Thank you for all the suggestions. Unfortunately, DistinctCountAudit_All_Categories = CALCULATE(DISTINCTCOUNT('Audits_and_Obs'[ID]),'Audits_and_Obs'[Type]="Audit",ALL('Audits_and_Obs')) did not work either (same output as before). Although I still don't understand why it is behaving that way, I found a solution to my problem. If I select the desired Category value and also select (Blank), I get the desired result.
v-yulgu-msft Super Contributor
Super Contributor

Re: DAX Measure - CALCULATE DISTINCTCOUNT with ALL not working as intended

Hi @huguest,

 

Would you please kindly share your solution so that it can benefit other community members having similar problem?

 

Regards,

Yuliana Gu

Community Support Team _ Yuliana Gu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
huguest Member
Member

Re: DAX Measure - CALCULATE DISTINCTCOUNT with ALL not working as intended

As mentioned in my previous post, my solution is more of a workaround. If I select the desired Category value and also select (Blank), I get the desired result. Thanks to everyone who tried to help!

Helpful resources

Announcements
Ask Amir Anything

Exclusive LIVE Community Event No. 2 – Ask Amir Anything

Next in our Triple A series: Ask Amir Netz questions about the latest updates, features and future.

Ask Amanda Anything Q&A

Ask Amanda Anything Q&A

Learn the answers to some of the questions asked during the Amanda Triple A event.

October 2019 Community Highlights

October 2019 Community Highlights

October was a busy month in the community. Read the recap article to learn about some of the events and content.

New Solution Badges

New Solution Badges

Two waves of brand new solution badges are coming! Read the article for more information on our new community badges.

Users Online
Currently online: 164 members 1,500 guests
Please welcome our newest community members: