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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
sarthakgirdhar
Frequent Visitor

Help displaying/calculating percentage in a stacked bar chart

Hi DAX champions,

I am trying to calculate/write a measure for the different categories/labels/legend in a stacked bar chart.

 

My table/data looks something like this:-

 

Table.png

 

I have student grades across multiple semesters. If I simply do an aggregate/count of student grades across semesters, it looks something like this (semester_code 202410 translates to 2023/2024 Fall) :- 

 

Visual.png

 

The semester code values are 201710, 201720, 201730, 201810, 201820,...,202330, 202410, 202420.

 

When looking at the tooltip, it looks like this:-

 

Tooltip.png

 

I want to write a DAX measure such that I can view the correct percentage (for the above scenario, 40.27%). 

 

This is what I have written:-

 

 

 

 

 

Student percent per Grade group = 
var student_total_per_term = CALCULATE(COUNT('Course Grade'[student_id]), ALLEXCEPT('Course Grade', 'Course Grade'[semester_code]))
return DIVIDE(COUNT('Course Grade'[course_grade (groups)]), student_total_per_term) 

 

 

 

 

 

I am not sure where I am going wrong and I would appreciate your help 🙂

 

 

Regards,

Sarthak

 

 

 
1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @sarthakgirdhar ,

Regarding your question, you are not using the column 'semeter_code' in your visual, so the filtering effect of keeping this column has no effect.

vzhouwenmsft_0-1720749255384.png

Change the column name to the one I marked.

vzhouwenmsft_1-1720749282371.png

vzhouwenmsft_2-1720749363305.png

For "202410", the correct value is 22.

vzhouwenmsft_3-1720749407350.png


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

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

Hi @sarthakgirdhar ,

Regarding your question, you are not using the column 'semeter_code' in your visual, so the filtering effect of keeping this column has no effect.

vzhouwenmsft_0-1720749255384.png

Change the column name to the one I marked.

vzhouwenmsft_1-1720749282371.png

vzhouwenmsft_2-1720749363305.png

For "202410", the correct value is 22.

vzhouwenmsft_3-1720749407350.png


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

Hi @Anonymous / Wenbin Zhou,

 

Thank you for taking the time to provide the solution. I am using a star schema and I was under the impression that the semester_code description would automatically be picked up, but apparently that's not the case. 

I will take it from here. Thank you for your help 🙂


Kind regards,

Sarthak

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

Find out what's new and trending in the Fabric community.

July PBI25 Carousel

Power BI Monthly Update - July 2025

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