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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Synik_PBI
Helper I
Helper I

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 I
Helper I

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 I
Helper I

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 I
Helper I

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
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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