Forum Discussion

Ndwhite's avatar
Ndwhite
Regular Visitor
1 year ago
Solved

How do I custom sort values in powerbi?

Hi! Former Tableau user here. How do I custom sort values in table in PowerBI? I just want to reorder certain items in a non-alphabetical and non-descending or ascending order. In Tableau, all you have to do is drag the values you want to reorder. Am I missing something here? 

 

I do not want to have to create custom dax queries and special reference columns to do simple things. 

  • Hi,

     

    You can add a Sort Column to your dataset to specify the order of the values you want. Then you can use the "Sort by Column" feature in Power BI to apply that custom sort order.

     

    Best Regards,
    Muhammad Yousaf

     

    LinkedIn

  • Anonymous's avatar
    Anonymous
    1 year ago

    Hi Ndwhite ,

     

    If you want to sort your column by asc or des, you can do this in Power Query Editor.

    If you want to customize the sorting of the columns, you need to add a reference column as mentioned above.

    As far as I know, it is not a good way to add the reference column in your table by IF or SWITCH (Dax) directly.
    Power BI will return a circule error if you sort by this column.

    It is better for you to add this reference column in Power Query Editor (M Query) or Dataset.
    You can also create a new table with unique key column and sort value then create a relationship with your data table.

    I think you can refer to this offical blog to learn how to use "Sort by column" function.

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

     

    Best Regards,
    Rico Zhou

     

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

4 Replies

  • Ndwhite , You can sort the column. You can have an order in that. But if You create a new column B from A to have sort order then you can mark B as Sort column A(Unless done in power query). So do like

     

    C= [A]

    B = Switch([A],

    "XY",1 ,

    "AB", 2 ) // Add more rows

     

    Now mark B as sort column on C and use C in visual

     

    Refer How to Create Sort Column and Solve Related Errors:
    https://www.youtube.com/watch?v=KK1zu4MBb-c

  • Hey Ndwhite 

     

    If you want to sort column A, in a custom way, then you need to add another column (let's call it B) with the number or alphabetic in a same way you wanna sort column A. Then select column A, in the column options, sort this column with column B and that will work.

     

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

    Appreciate your Kudos!! 

    LinkedIn|Twitter|Blog |YouTube 

  • muhammad_786_1's avatar
    muhammad_786_1
    Solution Supplier

    Hi,

     

    You can add a Sort Column to your dataset to specify the order of the values you want. Then you can use the "Sort by Column" feature in Power BI to apply that custom sort order.

     

    Best Regards,
    Muhammad Yousaf

     

    LinkedIn

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi Ndwhite ,

     

    If you want to sort your column by asc or des, you can do this in Power Query Editor.

    If you want to customize the sorting of the columns, you need to add a reference column as mentioned above.

    As far as I know, it is not a good way to add the reference column in your table by IF or SWITCH (Dax) directly.
    Power BI will return a circule error if you sort by this column.

    It is better for you to add this reference column in Power Query Editor (M Query) or Dataset.
    You can also create a new table with unique key column and sort value then create a relationship with your data table.

    I think you can refer to this offical blog to learn how to use "Sort by column" function.

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

     

    Best Regards,
    Rico Zhou

     

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