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
dawaro
Frequent Visitor

Custom Sort Help Needed

I am trying to build a table visual with two columns from my dataset, Priority and Actual Hours with a measure to calculate the percentage of Actual Hours/Total Hours for each priority.

 

What I need is to be able to custom sort the Priority column because their severity does not match their alphabetic order.

The order should be:

Priority

Actual HoursPercentage of Hours
Emergency22.55.2%
Schedule Break-In78.0

18.1%

Routine - High173.040.2%
Routine - Medium15.03.5%
Routine - Low142.040.2%
Total430.5100.0%

Emergency

Schedule Break-In

Routine - High

Routine - Medium

Routine - Low

 

I have tried to accomplish this with sort tables and sort columns as well as different measures but everything changes the Percentage of Hours to 100%.

 

What am I doing wrong?

1 ACCEPTED SOLUTION
v-kathullac
Community Support
Community Support

Hi @dawaro ,

Thank you for reaching out to Microsoft Fabric Community Forum.

can you follow the below steps and let us know if you need any assistance.


1)Create a separate table (manually or with DAX) to define your custom priority order:
PrioritySort = DATATABLE(
"Priority", STRING,
"SortOrder", INTEGER,
{
{"Emergency", 1},
{"Schedule Break-In", 2},
{"Routine - High", 3},
{"Routine - Medium", 4},
{"Routine - Low", 5}
}
)

2)In the Model view, create a relationship between your main data table's Priority column and the new sort table’s Priority.

3)Alternatively, merge the SortOrder column into your main data table in Power Query.

4)In the main data table, select the Priority column → click "Sort by Column" → choose SortOrder.

5)Create a measure for Total Actual Hours:
Total Actual Hours = SUM('Test'[Actual Hours])

6)Create a measure for Percentage of Hours:
Percentage of Hours = DIVIDE(SUM('Test'[Actual Hours]), CALCULATE(SUM('Test'[Actual Hours]), ALL('Test')))

7)Add a table visual with Priority, Actual Hours, and Percentage of Hours.

8)Ensure the table respects custom sort order and shows correct percentages.

 

Regards,

Chaithanya.

View solution in original post

6 REPLIES 6
dawaro
Frequent Visitor

Thank you that worked perfectly

v-kathullac
Community Support
Community Support

Hi @dawaro ,

Thank you for reaching out to Microsoft Fabric Community Forum.

can you follow the below steps and let us know if you need any assistance.


1)Create a separate table (manually or with DAX) to define your custom priority order:
PrioritySort = DATATABLE(
"Priority", STRING,
"SortOrder", INTEGER,
{
{"Emergency", 1},
{"Schedule Break-In", 2},
{"Routine - High", 3},
{"Routine - Medium", 4},
{"Routine - Low", 5}
}
)

2)In the Model view, create a relationship between your main data table's Priority column and the new sort table’s Priority.

3)Alternatively, merge the SortOrder column into your main data table in Power Query.

4)In the main data table, select the Priority column → click "Sort by Column" → choose SortOrder.

5)Create a measure for Total Actual Hours:
Total Actual Hours = SUM('Test'[Actual Hours])

6)Create a measure for Percentage of Hours:
Percentage of Hours = DIVIDE(SUM('Test'[Actual Hours]), CALCULATE(SUM('Test'[Actual Hours]), ALL('Test')))

7)Add a table visual with Priority, Actual Hours, and Percentage of Hours.

8)Ensure the table respects custom sort order and shows correct percentages.

 

Regards,

Chaithanya.

ExcelMonke
Super User
Super User

What does your percentage measure look like?





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!





This is the measure I am using to calculate the percentage of hours.

Percentage of Hours = DIVIDE(SUM('TestFile'[ACTUAL HOURS]),CALCULATE(SUM('TestFile'[ACTUAL HOURS]),ALL('TestFile'[PRIORITY])),0)
dawaro
Frequent Visitor

I have tried that and while it does correct the order it also changes the percentage for each row to 100%.

Here is the model:

TestFile2.jpg

 

 

 

 

 

 

 

 

Here is the result:

TestFile1.jpg

ExcelMonke
Super User
Super User

Hello, 

Sorting you columns can sometimes be tricky! My recommendation for you to consider is to create a secondary table for sorting purposes. It needs to only contain two columns like so:

Priority Sort Order

Emergency

1

Schedule Break-In

2

Routine - High

3

Routine - Medium

4
Routine - Low 5


From there, connect this table in your data model to your main fact table. You can then use the Priority column from this new table in your matrix, and sort by the table's sort order column. 

It's a bit convoluted, but it is a way to make it work! 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!





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.