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!To celebrate FabCon Vienna, we are offering 50% off select exams. Ends October 3rd. Request your discount now.
Hi DAX gurus,
I have some good news! AI won't be replacing us anytime soon. Both ChatGPT and CoPilot were unable to solve this.
All I am trying to do is write a dynamic DAX measure that calculates the percentage of students who obtained a grade X over the column total.
I have many filters/slicers on this page. As you can see in the attached image, the default tooltip for "100% stacked bar chart" gives the right percentage (15.38%, in this case) every time. I can change the filters that affects the total, and I still get the correct percentage.
My written DAX measure Grade Percentage fails to do so. I'd like your help in writing the correct DAX measure. I will eventually use this measure to create a customized Tooltip.
P.S. - The REPLY has the Data Model too.
Many thanks,
Sarthak
Solved! Go to Solution.
@sarthakgirdhar The classic approach to this would be something along the lines of:
% Total =
VAR _Total = CALCULATE( COUNTROWS( 'Course Grades' ), ALLSELECTED( 'Course Grades' ) )
VAR _Part = COUNTROWS( 'Course Grades' )
// or something like COUNTROWS( FILTER( 'Course Grades', [Grade] = "A" )
VAR _Return = DIVIDE( _Part, _Total )
RETURN _Return
Thank you for reaching out to the Microsoft Fabric Forum Community.
@GeraldGEmerick Thank you for your prompt response.
I'm glad your issue has been resolved. Please mark the helpful reply or your own response as the solution so it can assist others with similar issues.
@sarthakgirdhar The classic approach to this would be something along the lines of:
% Total =
VAR _Total = CALCULATE( COUNTROWS( 'Course Grades' ), ALLSELECTED( 'Course Grades' ) )
VAR _Part = COUNTROWS( 'Course Grades' )
// or something like COUNTROWS( FILTER( 'Course Grades', [Grade] = "A" )
VAR _Return = DIVIDE( _Part, _Total )
RETURN _Return
Hey @GeraldGEmerick,
Thank you for your reply!
I figured out the issue. It wasn't my DAX measure that was the issue, it was actually the "100% stacked Bar chart".
You see, the aforementioned visual already normalizes the values, and with my measure, there was double normalization that was happening hence, the wrong percentage. The calculation works just fine on the "normal" Stacked bar chart.
Glad to hear it!
THE DATA MODEL