Power BI is turning 10, and we’re marking the occasion with a special community challenge. Use your creativity to tell a story, uncover trends, or highlight something unexpected.
Get startedJoin us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.
I have the following situation: I have a table that assigns a school grade to each student per subject. Then I have a second mapping table that assigns a percentage value (100%, 85%, 75%, 65%, 50%) to each school grade (A, B, C, D, F).
Now I want to calculate the average grade in percent for each school subject. I have already found the following solution:
AverageEnglish = Calculate(average(Percentages[Percentage]),Filter(Grades, (Grades[Subject])="English"))
However, this solution is not correct because I am looking for a measure that calculates the average for each school subject and not just for one specific subject (in this case English). Also, the result is wrong because if two students have the same grade in a subject, the double values are left out of the calculation. See this example where two students have the grade "B" in English:
FormId | Students.Id | Subject | Grade |
1 | 1 | English | B |
2 | 2 | English | B |
3 | 3 | English | D |
4 | 1 | Maths | A |
5 | 2 | Maths | D |
6 | 3 | Maths | B |
Subject | AverageEnglish | AverageMaths |
English | 75% | |
Maths | 83,33% |
As you can see above, the result is therefore correct for mathematics but wrong for English. Does anyone have an idea how to solve this problem?
Solved! Go to Solution.
@Anonymous , Please find the attached file after signature.
Two solutions, using new column (then avg) and new measure
Please provide your feedback comments and advice for new videos
Tutorial Series Dax Vs SQL Direct Query PBI Tips
Appreciate your Kudos.
@Anonymous , the formula is correct , may be you need
AverageEnglish = Calculate(averagex(values(Table[School]), calculate(Percentages[Percentage])),Filter(Grades, (Grades[Subject])="English"))
Can you share sample data and sample output in table format? Or a sample pbix after removing sensitive data.
Please provide your feedback comments and advice for new videos
Tutorial Series Dax Vs SQL Direct Query PBI Tips
Appreciate your Kudos.
Hello!
I tried your measure but unfortunately it gives the same error, so the double values are left out.
I do not know how to share files on this board. But here are my sample tables:
Grades
FormId | Students.Id | Subject | Grade |
1 | 1 | English | B |
2 | 2 | English | B |
3 | 3 | English | D |
4 | 1 | Maths | A |
5 | 2 | Maths | D |
6 | 3 | Maths | B |
7 | 1 | French | A |
8 | 2 | French | C |
9 | 3 | French | B |
10 | 1 | Latin | B |
11 | 2 | Latin | A |
12 | 3 | Latin | F |
13 | 1 | Biology | B |
14 | 2 | Biology | B |
15 | 3 | Biology | A |
Percentages
Mapping.Id | Grade | Percentage |
Map1 | A | 100 |
Map2 | B | 85 |
Map3 | C | 75 |
Map4 | D | 65 |
Map5 | F | 50 |
GradeAverage (desired outcome):
English | 78,33% |
French | 86,67% |
Latin | 78,33% |
Maths | 83,33% |
Biology | 90% |
Actual wrong result:
Subject | Average |
English | 75% |
French | 86,67% |
Latin | 78,33% |
Maths | 83,33% |
Biology | 92,50% |
@Anonymous , Please find the attached file after signature.
Two solutions, using new column (then avg) and new measure
Please provide your feedback comments and advice for new videos
Tutorial Series Dax Vs SQL Direct Query PBI Tips
Appreciate your Kudos.
Thank you so much, that is exactly what I was looking for!
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
Check out the June 2025 Power BI update to learn about new features.
User | Count |
---|---|
10 | |
9 | |
7 | |
6 | |
5 |
User | Count |
---|---|
20 | |
11 | |
10 | |
9 | |
6 |