Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Stadeo
Frequent Visitor

Totals

New to Power BI.  I have 20 students that have to take 4 classes to meet training requirements

I'm trying to calcuate the percentage of students that have completed 0,1,2,3 or 4 classes

Is there a way to could the total column based on criteria (0,1,2,3,4) and divide by the total number of students.

 

Thanks in advance

 

 

 Class #1Class #2Class #3Class #4Total   
Student #311114   
Student #13 1113   
Student #4 1 12   
Student #51 1 2   
Student #81 1 2   
Student #15 11 2 0 class40%
Student #171  12 1 class20%
Student #19 11 2 2 class30%
Student #21   1 3 class5%
Student #7 1  1 4 class5%
Student #111   1   
Student #12  1 1   
Student #1    0   
Student #6    0   
Student #9    0   
Student #10    0   
Student #14    0   
Student #16    0   
Student #18    0   
Student #20    0   
1 ACCEPTED SOLUTION
MattAllington
Community Champion
Community Champion

You need to unpivot the data in the query editor so it has the following columns

 

student name, class name, value

 

when you have these three columns, you can just drag the columns Into your report and get the total column (put value column in the values section). Then write some measures such as 

classes completed = sum(table[value])

total students = distinctcount(table[student name])

0 class = divide(sumx(values(table[student name]),[classes completed]=0),[total students])

repeat for 1,2 etc



* Matt is an 8 times Microsoft MVP (Power BI) and author of the Power BI Book Supercharge Power BI.
I will not give you bad advice, even if you unknowingly ask for it.

View solution in original post

2 REPLIES 2
Zubair_Muhammad
Community Champion
Community Champion

Hi @Stadeo

 

Add the following Measure.

 

See the attached file as well

 

Percentage =
COUNT ( TableName[Total] ) / COUNTROWS ( ALL ( TableName ) )

Totals.jpg

MattAllington
Community Champion
Community Champion

You need to unpivot the data in the query editor so it has the following columns

 

student name, class name, value

 

when you have these three columns, you can just drag the columns Into your report and get the total column (put value column in the values section). Then write some measures such as 

classes completed = sum(table[value])

total students = distinctcount(table[student name])

0 class = divide(sumx(values(table[student name]),[classes completed]=0),[total students])

repeat for 1,2 etc



* Matt is an 8 times Microsoft MVP (Power BI) and author of the Power BI Book Supercharge Power BI.
I will not give you bad advice, even if you unknowingly ask for it.

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.