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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

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
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors
Top Kudoed Authors