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:
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 , 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.
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:
GradeAverage (desired outcome):
Actual wrong result:
Check out the November 2023 Power BI update to learn about new features.
130+ sessions, 130+ speakers, Product managers, MVPs, and experts. All about Power BI and Fabric. Attend online or watch the recordings.