Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
2 years ago
Solved

PowerBI - Created a custom column, how do I sort based on that Matrix

Hi, I created a custom column with the formula as so:

RequesterType =
IF('table'[opened by] = 'table'[subject person], "Self", "Other")

I dragged RequesterType into a matrix as a column and it populated fine. However, I cannot sort by 'self' or 'other' and can only sort by the total. 

I tried going to the top right corner to use 'sortby' but it doesnt show up

  • Hey Anonymous 

     

    The reason you can't sort by "Self" or "Other" directly in your matrix is because Power BI sorts by the underlying data type, which in this case is text. "Self" and "Other" are treated alphabetically, meaning "Other" would come before "Self" even though you want it the other way around.

    Here are one  way to solve this and sort by "Self" and "Other" as intended:

    Sort by a Numeric Value

    1. Create another calculated column based on your RequesterType column. This new column will assign a numerical value to "Self" and "Other" for sorting purposes.
    2. Go to Modeling view in Power BI Desktop.
    3. Right-click on the RequesterType column and select Sort By Column.
    4. In the Sort By Column panel, choose the column that you create.

    With this approach, you should now be able to sort your matrix by "Self" and "Other" as intended.

  • Anonymous's avatar
    Anonymous
    2 years ago

    Hi, Anonymous 

     

    Thanks for the reply from marcelsmaglhaes, please allow me to provide another insight

     

    Double-check the formula that created the column for any potential issues. Make sure it's properly applied and visible in the data model.

     

    In the matrix visual, click the drop-down arrow next to the column heading. Look for sorting options here. If you can't sort directly, consider using the More Options menu for additional sorting configurations.

     

    If the above steps don't work, consider creating a measure that counts the number of occurrences of "Self" and "Other" and using this measure as a sort reference in your visual. For a more detailed guide to sorting in Power BI, you can check out the documentation below:

     

    Sort one column by another column in Power BI - Power BI | Microsoft Learn

     

    How to Get Your Question Answered Quickly 

    Best Regards

    Yongkang Hua

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

2 Replies

  • Hey Anonymous 

     

    The reason you can't sort by "Self" or "Other" directly in your matrix is because Power BI sorts by the underlying data type, which in this case is text. "Self" and "Other" are treated alphabetically, meaning "Other" would come before "Self" even though you want it the other way around.

    Here are one  way to solve this and sort by "Self" and "Other" as intended:

    Sort by a Numeric Value

    1. Create another calculated column based on your RequesterType column. This new column will assign a numerical value to "Self" and "Other" for sorting purposes.
    2. Go to Modeling view in Power BI Desktop.
    3. Right-click on the RequesterType column and select Sort By Column.
    4. In the Sort By Column panel, choose the column that you create.

    With this approach, you should now be able to sort your matrix by "Self" and "Other" as intended.

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi, Anonymous 

     

    Thanks for the reply from marcelsmaglhaes, please allow me to provide another insight

     

    Double-check the formula that created the column for any potential issues. Make sure it's properly applied and visible in the data model.

     

    In the matrix visual, click the drop-down arrow next to the column heading. Look for sorting options here. If you can't sort directly, consider using the More Options menu for additional sorting configurations.

     

    If the above steps don't work, consider creating a measure that counts the number of occurrences of "Self" and "Other" and using this measure as a sort reference in your visual. For a more detailed guide to sorting in Power BI, you can check out the documentation below:

     

    Sort one column by another column in Power BI - Power BI | Microsoft Learn

     

    How to Get Your Question Answered Quickly 

    Best Regards

    Yongkang Hua

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.