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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
samnaw
Resolver I
Resolver I

DISTINCT COUNT AND GROUP BY

Hello:

 

I am trying to do GROUP BY in a DAX statement with DISTINCT COUNT. 

 

When I use this formula I get this:

 

CALCULATE
    (DISTINCTCOUNT(Table_1[Dim_1]),
        FILTER(Table_1,Table_1[Dim_1]="xyz")
        )
 
89 unique programs for YTD
ProgramCount
Program_134
Program_220
Program_335
Total89

 

But I would like this number to show up GROUP BY month:

 

MonthCount
September78
October88
Total166

 

I want it to DISTINCT(COUNT) by Month and then SUM. 

 

ProgramCount
Program_154
Program_240
Program_372
Total166

 

2 REPLIES 2
v-rzhou-msft
Community Support
Community Support

Hi @samnaw ,

 

According to your statement, I still have some questions. I am confused about DISTINCTCOUNT YTD = 89, however DISTINCTCOUNT MONTH = 166. Please share a sample file with me and show me a screenshot with the result you want.

 

Best Regards,
Rico Zhou

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Greg_Deckler
Super User
Super User

@samnaw First, please vote for this idea: https://ideas.powerbi.com/ideas/idea/?ideaid=082203f1-594f-4ba7-ac87-bb91096c742e

This looks like a measure totals problem. Very common. See my post about it here: https://community.powerbi.com/t5/DAX-Commands-and-Tips/Dealing-with-Measure-Totals/td-p/63376

Also, this Quick Measure, Measure Totals, The Final Word should get you what you need:
https://community.powerbi.com/t5/Quick-Measures-Gallery/Measure-Totals-The-Final-Word/m-p/547907

Also: https://youtu.be/uXRriTN0cfY
And: https://youtu.be/n4TYhF2ARe8


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

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.