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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
Krc721
Helper I
Helper I

Need help with a combination sort order in Power BI

I am still somewhat new to Power BI.  I have a situation where I need to show the top N (in this case N is 5) records based upon the following:

1) Sorting of PassRate

2) After PassRate is sorted, then take the Top 5 records where RecNum are the largest.  

 

Additionally, the PassRate is a Measure dividing the total records completed / total records attempted.  This needs to be precise so 99.99 should show 99.9 not 100.0.  I used a format command around the measure calculation from the two rows; however, that is text so when I tried to do anything with that it failed because of the data type.  I tried to create a new column and put the calcualtion in and I believe it may have worked; however, when I put it in the visual it is a sum of and not the decimal number as seen in the data table. 

Thanks

4 REPLIES 4
Krc721
Helper I
Helper I

Thank you for your reply.  I mocked up some data since I cannot share the actual items.

The table below shows 12 different students.  Transferring my scenarios to sample data, the requirements are as follows:

1) Calculate the Performance Percentage to 1 decimal point (do not round so if 99.9 do not round to 100.0)

2) Provide the Top N (N= 5) student IDs for those that have the worst performance based the percentage (column B) weighted by the Total Assignments Failed (Column D).

If we go only off performance percentage we get student 005, 001, 002, 004 and 003 (the first 5 listed); however, we want those that attempted and failed more students 002, 003, 008,006, and 007.

 

 Performance PercentTotal Assignments PassedTotal Assignments FailedTotal Assignments
Student 005 50.00112
Student 001 70.007030100
Student 002 70.00350001500050000
Student 004 81.25650150800
Student 003 90.0022500025000250000
Student 008 91.5032217299435211
Student 006 91.5073200006800008000000
Student 007 95.0024383712833256670
Student 009       99.9925666225666
Student 010100.0034538034538
Student 011100.009098660909866
Student 012100.0012223334012223334
Fowmy
Super User
Super User

@Krc721 

Thank you for your explanation and it will be helpful if you could provide some sample data and the expected results so that I'll be able to workout a solution. You can copy paste from your sample data from an excel in your reply or attach a Excel file after saving it in Google drive or onedrive 

Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

Update, tried some DAX, something is still off:

Scores is the database in sample

All (takes off the filter - although I do need to filter NaNs out - not in my sample but in real data set).  

The numbering begins at 2 not 1 (not sure why)

And the sort is accurate for the first column (sorts the Performance Percent in proper ascending order; however, the column for pass (the weighting column) is not sorting.

Rank Lowest Pct Highest Fail =
  RANKX(ALL('Scores'[student_id]), [Performance_Percent], , ASC, Dense) +  RANKX(ALL('Scores'[student_id]), (SUM(Scores[total_assignments_failed])), , DESC, Dense)

@Fowmy   I posted a reply, i think it went to the main thread on my post.  Thank you for your response.  If you have questions let me know.

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.

Top Solution Authors