Forum Discussion

E_K_'s avatar
E_K_
Icon for Helper III rankHelper III
1 year ago
Solved

Sort in 2 ways at once one visual single dataset

Hi there

 

I have the below table, made up of fields from 'RiskRegister.

I have a sort column for the ([Source Name] that orders the sources as RCI,Audit Issue,RCSA Action,RCI Action,Audit Action, and Op Event Action from top to bottom. I just need to somehow sort the values from the [Status] column  to read from left to right:  Past Due, Due in < 30 days, and Open, not alphabetically as default.

What do I do? I can't sort 2 different columns within the same dataset by 2 different columns. Using a combined sort order for both didn't work for me.

Below is the final table as displayed in my desktop. The source name is sorted but the statuses are not : 

 

Source NameDue in < 30 DaysOpenPast Due
RCI131
Audit Issue121
RCI Action131
RCI Action151
Audit Action132
Op Event Action153

 

  • Hi E_K_ 

    In the query editor create a conditional column that returns a sort values.

    Use this to custom sort the Status column by

    Do the same for Source Name if you want a different sort order.

     

7 Replies

  • Source Name and Status are two different columns, therefore you can sort them by the values of another column

     

    For the Status if you do not have already a suitable table, you can create it (insert data in Power BI Desktop)

     

    Status                        Order

    Past Due                      1
    Due in < 30 days         2
    Open                           3

     

    Connect this table 1 to many to the Fact table, bring the Order in the Fact table trhough a calculated column using the RELATED function and sort Status via the values of Order

     

    If this helped, please consider giving kudos and mark as a solution

    me in replies or I'll lose your thread

    consider voting this Power BI idea

    Francesco Bergamaschi

    MBA, M.Eng, M.Econ, Professor of BI

  • Hi E_K_ 

    In the query editor create a conditional column that returns a sort values.

    Use this to custom sort the Status column by

    Do the same for Source Name if you want a different sort order.

     

  • Hi E_K_ ,

     

     

    You've got a classic Power BI sorting challenge here. Both responses you received are correct, but let me give you the complete solution.

    FBergamaschi 's approach is the best practice method:

    Step 1: Create a Status Sort Table Go to Home → Enter Data and create:

    Status               Sort Order
    Past Due             1
    Due in < 30 days     2  
    Open                 3

    Step 2: Create Relationship

    • Model view → Drag from Status Sort Table[Status] to your main table[Status]
    • Set as 1:Many relationship

    Step 3: Sort the Status Column

    • Data view → Select Status column
    • Column tools → Sort by Column → Select "Sort Order"

    Step 4: For Source Name (if you need custom sorting) Create another table:

    Source Name          Sort Order
    RCI                  1
    Audit Issue          2  
    RCI Action           3
    Audit Action         4
    Op Event Action      5

    Follow the same relationship and sorting steps.

    Alternative: Query Editor Method If you prefer the conditional column approach:

    • Transform Data → Add Column → Conditional Column
    • Create rules for Status sorting (Past Due = 1, etc.)
    • Sort Status by this new column

    Both methods work, but the separate table approach is cleaner for maintenance and reusability across multiple reports.


    If my response resolved your query, kindly mark it as the Accepted Solution to assist others. Additionally, I would be grateful for a 'Kudos' if you found my response helpful.

    This response was assisted by AI for translation and formatting purposes.

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi E_K_,

    Thanks for reaching out to the Microsoft fabric community forum.

    You qre right that Power BI visuals like the matrix don't let you directly sort two different columns by two different fields within the same table. However, as FBergamaschi and others suggested the workaround to create sort helper tables and then link them to your fact table. Kindly go through their responses and check if your issue can be resolved.

     

    I would also take a moment to thank burakkaragoz, danextian and FBergamaschi`, for actively participating in the community forum and for the solutions you’ve been sharing in the community forum. Your contributions make a real difference.

     

    If I misunderstand your needs or you still have problems on it, please feel free to let us know.  

    Best Regards,
    Hammad.

    • Anonymous's avatar
      Anonymous
      Not applicable

      Hi E_K_,

      As we haven’t heard back from you, so just following up to our previous message. I'd like to confirm if you've successfully resolved this issue or if you need further help.

      If yes, you are welcome to share your workaround so that other users can benefit as well.  And if you're still looking for guidance, feel free to give us an update, we’re here for you.

       

      Best Regards,

      Hammad.

      • Anonymous's avatar
        Anonymous
        Not applicable

        Hi E_K_,
        Hope everything’s going smoothly on your end. As we haven’t heard back from you, so I wanted to check if the issue got sorted.
        Still stuck? No worries just drop us a message and we can jump back in on the issue.

         

        Best Regards,

        Hammad.