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
Synik_PBI
Helper II
Helper II

Help with sorting a table column text field

Hello! I was hoping to get some thoughts on if I'm missing something when sorting a table column visual. Here is the current sorting structure of the table: 

Synik_PBI_0-1679415831613.png

As well as the DAX logic for the Review Priority column:

 

 

 

Review Priority = 

SWITCH(
    TRUE(),
    'Main data'[Inherent Risk Score] = "5" && 'Main data'[Review Notification] = "Out of compliance",
    "#1 Priority",
    'Main data'[Inherent Risk Score] = "4" && 'Main data'[Review Notification] = "Out of compliance",
    "#2 Priority",
    'Main data'[Inherent Risk Score] = "3" && 'Main data'[Review Notification] = "Out of compliance",
    "#3 Priority",
    'Main data'[Inherent Risk Score] = "5" && 'Main data'[Review Days] >=0 && 'Main data'[Review Days] <=30,
    "#4 Priority",
    'Main data'[Inherent Risk Score] = "4" && 'Main data'[Review Days] >=0 && 'Main data'[Review Days] <=30,
    "#5 Priority",
    'Main data'[Inherent Risk Score] = "3" && 'Main data'[Review Days] >=0 && 'Main data'[Review Days] <=30,
    "#5 Priority",
    --'Main data'[Inherent Risk Score] = "5" && 
    'Main data'[Review Days] >=31 && 'Main data'[Review Days] <=730,
    "#6 Priority",
    // 'Main data'[Inherent Risk Score] = "4" && 'Main data'[Review Days] >=31 && 'Main data'[Review Days] <=730,
    // "#7 Priority",
    // 'Main data'[Inherent Risk Score] = "3" && 'Main data'[Review Days] >=31 && 'Main data'[Review Days] <=730,
    // "#8 Priority",
    FORMAT('Main data'[Review Days], "####")
    )

 

 

 

The Review Days are a simple DATEDIFF from the Review Date to TODAY() The Review Notification is just a bucketing of certain Review Days ranges and IR Score is just a whole number. 

 

What I'm trying to do is sort the column by the correct Review Priority nominclature. In the above screenshot, the sorting is working correctly. I am taking the highest IR Score into account along with the lowest Review Day to obtain a priority list. This is correctly functioning for both red and yellow colors. 

Here is where the sorting is off: 

Synik_PBI_1-1679416189323.png

In this case I am trying to not take the IR score into account anymore, as seen in the DAX code. When I leave out the IR Score component, the sorting on Days just becomes illogical. Further more, if I change the code to ignore any sort of Priority and just display the Days:

Synik_PBI_2-1679416416066.png

I am forced to change the Days value into a text (as expected), but this leads to a text-type sorting, which is definitely not what I want. 

So, to summarize- I'm trying to sort on Priority 1-3 at the top, but don't really care about sorting anything beyond that other than having it respect the numerical Days sorting. Is there a way to accomplish this or is this just what I have to deal with when sorting by text? 

I've love to hear peoples thoughts, hopefully I missed some sorting logic somewhere! Thank you! 

1 ACCEPTED SOLUTION
Synik_PBI
Helper II
Helper II

Just in case anyone has a similar issue, I solved this problem by creating a new table. 

Priority Sort Table =

GROUPBY(
    'Main data',
    'Main data'[Review Priority]
)

Then the column that handels the sorting is made like this: 
SWITCH(
    TRUE(),
    LEN( 'Priority Sort Table'[Review Priority] ) < 3,
    CONCATENATE( "0", 'Priority Sort Table'[Review Priority] ),
    'Priority Sort Table'[Review Priority]
)
I then made a relationship on the Review Priority and use the Adjusted inside the visual. 

View solution in original post

2 REPLIES 2
Synik_PBI
Helper II
Helper II

Just in case anyone has a similar issue, I solved this problem by creating a new table. 

Priority Sort Table =

GROUPBY(
    'Main data',
    'Main data'[Review Priority]
)

Then the column that handels the sorting is made like this: 
SWITCH(
    TRUE(),
    LEN( 'Priority Sort Table'[Review Priority] ) < 3,
    CONCATENATE( "0", 'Priority Sort Table'[Review Priority] ),
    'Priority Sort Table'[Review Priority]
)
I then made a relationship on the Review Priority and use the Adjusted inside the visual. 
Synik_PBI
Helper II
Helper II

Apologies, but I'm bumping this thread, I'd love either a solution to the sorting issue, or a confirmation and possibly explaination that this is working as intended. Many thanks! 

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.