Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
1 year ago
Solved

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.

 

 

 

IDYearGroupResult
12015APass
22015APass
32015AFail
42015BFail
52015BFail
62015BPass
72015CFail
82015CPass
92015CPass
102015CPass
112016APass
122016AFail
132016BPass
142016BFail
152016BFail
162016BPass
172016BFail
182016CPass
192016CPass
202016CFail
212017APass
222017APass
232017AFail
242017AFail
252017BPass
262017CFail
272017CFail
282017CPass
292017CPass
302017CPass

 

  • Anonymous , Try a measure like

    Divide(countrows(filter(Table, Table[Result]= "Pass")) , countrows(Table))  )

    Mark that as % column 

3 Replies

  • Anonymous , Try a measure like

    Divide(countrows(filter(Table, Table[Result]= "Pass")) , countrows(Table))  )

    Mark that as % column 

  • v-dineshya's avatar
    v-dineshya
    Icon for Community Support rankCommunity 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