Power BI is turning 10! Tune in for a special live episode on July 24 with behind-the-scenes stories, product evolution highlights, and a sneak peek at what’s in store for the future.
Save the dateEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
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:-
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) :-
The semester code values are 201710, 201720, 201730, 201810, 201820,...,202330, 202410, 202420.
When looking at the tooltip, it looks like this:-
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
Solved! Go to Solution.
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.
Change the column name to the one I marked.
For "202410", the correct value is 22.
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 @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.
Change the column name to the one I marked.
For "202410", the correct value is 22.
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
User | Count |
---|---|
25 | |
12 | |
8 | |
6 | |
6 |
User | Count |
---|---|
26 | |
12 | |
11 | |
10 | |
6 |