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

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

Reply
Anonymous
Not applicable

How to add grant total to unstacked bar chart with hierarchy

Hi everyone,

I have been trying to add grant totals bar for unstacked (clustered) bar chart that depends on two measures(values), and this is clustered by a hierarchy (Region>Countries>Sites), I could reach the goal for Regions as this solution https://community.powerbi.com/t5/Desktop/Grand-Total-in-Bar-Chart/td-p/612631 , but when I try to mimic it for the following hierarchies it gives me grant totals for every country or site which has zero values. Do you know some trick to achieve this approach?

ExampleFile.pbix

 

K_Caballero16_0-1608281045125.png

 

1 ACCEPTED SOLUTION
AllisonKennedy
Super User
Super User

@Anonymous 

Thank you for providing the additional info and sample file. The key was knowing what formula you were using. 

 

You need to update your measure to: 

 

Measure = var amount = sum(Amounts[Amount]) return if(SELECTEDVALUE(DimLocations[Unit]) = "Grant Total", CALCULATE(sum(Amounts[Amount]), ALLEXCEPT(Amounts, Amounts[Year])), amount)
 
You had it as: 
 
Measure = var amount = sum(Amounts[Amount]) return if(ISBLANK([amount]), CALCULATE(sum(Amounts[Amount]), ALLEXCEPT(Amounts, Amounts[Year])), amount)
 
But the condition in bold is looking for empty amounts, and as you discovered, this can happen not just in Grand Total row, but where you have no data. So I have updated it to reference Grand Total row by name explicitly.
 
 

 


Please @mention me in your reply if you want a response.

Copying DAX from this post? Click here for a hack to quickly replace it with your own table names

Has this post solved your problem? Please Accept as Solution so that others can find it quickly and to let the community know your problem has been solved.
If you found this post helpful, please give Kudos C

I work as a Microsoft trainer and consultant, specialising in Power BI and Power Query.
www.excelwithallison.com

View solution in original post

5 REPLIES 5
AllisonKennedy
Super User
Super User

@Anonymous 

Thank you for providing the additional info and sample file. The key was knowing what formula you were using. 

 

You need to update your measure to: 

 

Measure = var amount = sum(Amounts[Amount]) return if(SELECTEDVALUE(DimLocations[Unit]) = "Grant Total", CALCULATE(sum(Amounts[Amount]), ALLEXCEPT(Amounts, Amounts[Year])), amount)
 
You had it as: 
 
Measure = var amount = sum(Amounts[Amount]) return if(ISBLANK([amount]), CALCULATE(sum(Amounts[Amount]), ALLEXCEPT(Amounts, Amounts[Year])), amount)
 
But the condition in bold is looking for empty amounts, and as you discovered, this can happen not just in Grand Total row, but where you have no data. So I have updated it to reference Grand Total row by name explicitly.
 
 

 


Please @mention me in your reply if you want a response.

Copying DAX from this post? Click here for a hack to quickly replace it with your own table names

Has this post solved your problem? Please Accept as Solution so that others can find it quickly and to let the community know your problem has been solved.
If you found this post helpful, please give Kudos C

I work as a Microsoft trainer and consultant, specialising in Power BI and Power Query.
www.excelwithallison.com

Anonymous
Not applicable

Hi  @Anonymous ,

 

Your columns [inv] and [olu] have 0 in the data, so the value of 0 will be displayed

 

Best Regards,

Liu Yang

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

amitchandak
Super User
Super User

@Anonymous , You a create line clustered visual and Line with the marker. And you can have line color same background color.

Refer to this example

https://radacad.com/showing-the-total-value-in-stacked-column-chart-in-power-bi

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
AllisonKennedy
Super User
Super User

Do you have dimension tables or is it all in one table? Please can you provide sample of your data model with the blank values. You need to find the right modified filter context, probably using ALL() or ALLSELECTED or ALLEXCEPT, etc. Please give as much info as possible about what filters you have on the page too and what to respect and ignore.


Please @mention me in your reply if you want a response.

Copying DAX from this post? Click here for a hack to quickly replace it with your own table names

Has this post solved your problem? Please Accept as Solution so that others can find it quickly and to let the community know your problem has been solved.
If you found this post helpful, please give Kudos C

I work as a Microsoft trainer and consultant, specialising in Power BI and Power Query.
www.excelwithallison.com

Anonymous
Not applicable

I attached the sample file

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!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

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.