Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
huguest
Advocate II
Advocate II

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
v-yulgu-msft
Employee
Employee

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.

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.

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.

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!
AlB
Super User
Super User

Hi @huguest

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

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

@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?

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.

@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.

 

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

Find out what's new and trending in the Fabric Community.