Forum Discussion

altchung's avatar
altchung
Frequent Visitor
5 years ago

Reordering list

Hi Everyone,

 

I have a list which is shown below.  I can sort them Store Count (smallest to largest or vice versa), or Store Priority (alphabetically).

 

It there a way to write some code to customise the sort.  Ideally, I would like to sort them as follows - 

 

1. High Priority

2. Medium Priority

3. Low Priority

4. No replacement in Year 0

 

 

Many thanks,

 

Annie

3 Replies

  • AllisonKennedy's avatar
    AllisonKennedy
    Community Champion

    altchung  You either need to add a new column in Power Query, or add a new table. 

     

    For Power Query: 

    Click Transform Data

    In Power Query click Add Column tab in ribbon

    Choose Conditional column

    Put in your conditions for high, med, low, other so that each value in the existing column has a different number. Name this column [Priority Sort]

    Close and Apply changes.

    Click on the Store Priority column to activate the Column Tools tab in ribbon > Click Sort by Column > Choose the new [Priority Sort] column you just created. 

     

    Now whenever you sort a visual by Store Priority, it will sort by the numeric column instead of alphabetically.

    • altchung's avatar
      altchung
      Frequent Visitor

      Thank you for your response.  Apologies, I was not clear in my request.  I don't think I can use a conditional column as the priority is a calculated measure, which therefore doesn't appear in the Power Query.

      • v-easonf-msft's avatar
        v-easonf-msft
        Community Support

        Hi, altchung 

        Could you please share a sample pbix file and expected result for research?

         

        Best Regards,
        Community Support Team _ Eason