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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
DebbieE
Community Champion
Community Champion

Possible odd DAX Behaviour of a DISTINCTCOUNT of a dimension key

I have created the following DAX to get the count of all records in a dimension (Getting rid of NAs)

 

Possible odd DAX Behaviour of a DISTINCTCOUNT of a dimension key

 

# Entities across Company = CALCULATE(DISTINCTCOUNT('Dim'[Key]), 'Dim'[Sub Term] <> "NA")
 
If I add it into a table with the key its fine
DAXwithKey.png
Its counting 16 of them without the NA row. However. When I remove the table from the key it goes wrong
 
DAXwithoutKey.png
Now each row shows as 16. I cant work out what I have done wrong in the DAX apart from use the key but normally this works fine. 
 
Is there anything I can do with the DAX so it counts each record once even without the key in the table?
 
Thanks in advance
 
1 ACCEPTED SOLUTION
MFelix
Super User
Super User

Hi @DebbieE ,

 

This has to do with the context and the way the calculate works. The use of calculate with a filtering when applied make the same calculation has a filter all.

 

In your case when you take out the ID from the measure it will pick up all the values from the ID and then getting the 16 instead of 1 for each of the values.

 

Check the link about the CALCULATE and how it works.

https://dax.guide/calculate/

 

 

Context is everything especcially when working with calculate, in this case you should substitute the ID by the SUBTERM and believe you will get the correct result.


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



View solution in original post

1 REPLY 1
MFelix
Super User
Super User

Hi @DebbieE ,

 

This has to do with the context and the way the calculate works. The use of calculate with a filtering when applied make the same calculation has a filter all.

 

In your case when you take out the ID from the measure it will pick up all the values from the ID and then getting the 16 instead of 1 for each of the values.

 

Check the link about the CALCULATE and how it works.

https://dax.guide/calculate/

 

 

Context is everything especcially when working with calculate, in this case you should substitute the ID by the SUBTERM and believe you will get the correct result.


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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