Forum Discussion
Pass/fail rate for groups across time
Hello,
In context, I need the y-axis to be the percentage of students that passed a course, and I will label each data point with the correct percentage.
For example, for group B, the labels should be 33% in 2015, 40% in 2016, and 100% in 2017.
| ID | Year | Group | Result |
| 1 | 2015 | A | Pass |
| 2 | 2015 | A | Pass |
| 3 | 2015 | A | Fail |
| 4 | 2015 | B | Fail |
| 5 | 2015 | B | Fail |
| 6 | 2015 | B | Pass |
| 7 | 2015 | C | Fail |
| 8 | 2015 | C | Pass |
| 9 | 2015 | C | Pass |
| 10 | 2015 | C | Pass |
| 11 | 2016 | A | Pass |
| 12 | 2016 | A | Fail |
| 13 | 2016 | B | Pass |
| 14 | 2016 | B | Fail |
| 15 | 2016 | B | Fail |
| 16 | 2016 | B | Pass |
| 17 | 2016 | B | Fail |
| 18 | 2016 | C | Pass |
| 19 | 2016 | C | Pass |
| 20 | 2016 | C | Fail |
| 21 | 2017 | A | Pass |
| 22 | 2017 | A | Pass |
| 23 | 2017 | A | Fail |
| 24 | 2017 | A | Fail |
| 25 | 2017 | B | Pass |
| 26 | 2017 | C | Fail |
| 27 | 2017 | C | Fail |
| 28 | 2017 | C | Pass |
| 29 | 2017 | C | Pass |
| 30 | 2017 | C | Pass |
Anonymous , Try a measure like
Divide(countrows(filter(Table, Table[Result]= "Pass")) , countrows(Table)) )
Mark that as % column
3 Replies
- amitchandak
Super User
Anonymous , Try a measure like
Divide(countrows(filter(Table, Table[Result]= "Pass")) , countrows(Table)) )
Mark that as % column - Ashish_Mathur
Super User
- v-dineshya
Community Support
Hi Anonymous ,
Thanks for reaching out to the Microsoft fabric community forum.
To calculate the percentage of students who passed a course for each group and year, you can follow these steps in Power BI:
1.Create a table with your data: Ensure that your data is correctly loaded into Power BI with the columns ID, Year, Group, and Result.
2.Create a measure for the pass percentage: You need to calculate the pass percentage for each combination of Group and Year. You can create a new measure for this in Power BI.
Use the following DAX formula to create the measure:
Pass Percentage =
VAR TotalStudents = COUNTROWS('Table') -- This counts the total number of students for the specific group and year.
VAR PassedStudents = COUNTROWS(FILTER('Table', 'Table'[Result] = "Pass")) -- This counts the number of students who passed.
RETURN
IF(TotalStudents > 0, (PassedStudents / TotalStudents) * 100, 0)
Plot the data:Create a Line chart visualization in Power BI. Add Year to the Axis. Add Group to the Legend to differentiate between the groups. Add the Pass Percentage measure to the Values field.
Display percentage labels: To display the percentage on the chart:
Click on the chart to select it. In the Visualizations pane, go to the Format tab. Turn on Data labels to display the percentages on each point in the chart.
If you find this post helpful, please mark it as an "Accept as Solution" and consider giving a KUDOS. Feel free to reach out if you need further assistance.
Thanks and Regards