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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Anonymous
Not applicable

Distinct Count of Material going wrong at Grand Total level of a group

Hello experts,

 

I am facing an issue with Distinct Count at grand total. Please find the below screenshot and help me. I have used below formula for bucketing.

 
21-45 Dayss =
var a =  'Planning- DOI'[DOI]
var b = CALCULATE(sumx(values('Planning- DOI'[Parent Material.Parent Material Level 01.Key]), a))
var c = if(AND((b>=21 && b<=45), 'Planning- DOI'[DOI]>0),int(1),0)
var d = IF(HASONEVALUE('Planning- DOI'[Parent Material.Parent Material Level 01.Key]), c, SUMX(VALUES('Planning- DOI'[SCC.SCC Level 01.Key]), c))
return d
 
21-45 Dayy = IF(HASONEVALUE('Planning- DOI'[Parent Material.Parent Material Level 01.Key]), 'Planning- DOI'[21-45 Dayss], SUMX(VALUES('Planning- DOI'[Parent Material.Parent Material Level 01.Key]), 'Planning- DOI'[21-45 Dayss]))
 

Ajay_Emmadi_0-1672167183908.png

For 21-45 Dayy measure at sub total level the values are displayed correct but at Grand total level the total count should be 3 since there are only 3 distinct values. 

 

Regards,

Ajay

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@Anonymous , For correct grand total, you need measure like

 

Sumx(Summarize('Planning- DOI','Planning- DOI'[Parent Material.Parent Material Level 01.Key]), [21-45 Dayy])

 

you can add another column in row of matrix to summarize

 

 

refer: https://www.youtube.com/watch?v=ufHOOLdi_jk

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

View solution in original post

4 REPLIES 4
Ashish_Mathur
Super User
Super User

Hi,

Share some data, describe the question and show the expected result.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
amitchandak
Super User
Super User

@Anonymous , For correct grand total, you need measure like

 

Sumx(Summarize('Planning- DOI','Planning- DOI'[Parent Material.Parent Material Level 01.Key]), [21-45 Dayy])

 

you can add another column in row of matrix to summarize

 

 

refer: https://www.youtube.com/watch?v=ufHOOLdi_jk

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
Anonymous
Not applicable

Dear @amitchandak ,

 

Thanks for the immediate response. Please find the below screenshot and a sample file. 

Sample file 

Data file 

 

Ajay_Emmadi_0-1672204399719.png

Regards,

Ajay

Hi,

This question can be solved with just 2 measures.  See the second table in the screenshot.  You may download my PBI file from here.

Hope this helps.

Untitled.png


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

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 Kudoed Authors