web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Sort based on specific...
Power Automate
Answered

Sort based on specific values

(0) ShareShare
ReportReport
Posted on by 7

Hi, I am trying to add an action to my flow to sort my records. Now I know I will need to add a compose action and sort function to it. I am having trouble because the column I want to use for Sort has three specific values: Holiday, Permanent, and Temporary. So if I use sort it will be sorted like this. But, I want to sort it in this order: Permanent, Temporary and Holiday. Can anyone please guide me on how to do it?

Categories:
  • jitheshk Profile Picture
    100 on at

    A workaround to this requirement will be to add a column and assign 1 for Permanent, 2 for Temporary and 3 for Holiday and sort based on that Column.

  • Manish Solanki Profile Picture
    15,169 Moderator on at

    Hi @Maisum 

     

    I have a workaround for you, use 2 "Filter array" actions. In First filter action, get items containing Holiday using query. In another "Filter array", filter records which does not contains Holiday. Sort, the output of second array which will give you result in order "Permanent, Temporary". Finally, join both arrays using 'union' function to get the desired output.

     

    You may refer the logic mentioned in one of my previous replies:

    Solved: Sorting Column in HTML Table with Blank Fields at ... - Power Platform Community (microsoft.com)

     

     

     

     

    If this helps & solves your problem, please remember to give a 👍 and accept my solution as it will help others in the future.

     

  • SanmeshG Profile Picture
    1,956 Moderator on at

    Hi @Maisum ,

     

    What @ManishSolanki  suggested also works , alternatively you can try the below approach as well. Add  a column named Priority and assign a value to each priority and sort the array based on the Priority column.

     

    The if expression , in the select action ,

     

    if(equals(item()?['Clasification'],'Permanent'),1,
    if(equals(item()?['Clasification'],'Temporary'),2,
    if(equals(item()?['Clasification'],'Holiday'),3,0)))

     

    SanmeshG_1-1717395172339.png

     

    Hope this helps !

     

    Thanks,
    Sanmesh

     

  • Verified answer
    v-yetonggu-msft Profile Picture
    Microsoft Employee on at

    Hi @Maisum ,

    Please check this test:

    My SharePoint List:

    vyetonggumsft_3-1717395802462.png

    My Flow:

    vyetonggumsft_4-1717395970462.png

    vyetonggumsft_6-1717396149062.png

     

    if(equals(item()?['Sort/Value'],'Permanent'),1,
    if(equals(item()?['Sort/Value'],'Temporary'),2,
    3))
    
    sort(body('Select'),'Value')
    
    if(equals(item()?['Value'],1),'Permanent',
    if(equals(item()?['Value'],2),'Temporary',
    'Holiday'))
    
    item()?['Title']

     

    Best Regards,

    Sunshine Gu

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Automate

#1
11manish Profile Picture

11manish 302 Super User 2026 Season 2

#2
Mohsin Ali Profile Picture

Mohsin Ali 263

#3
Henil Profile Picture

Henil 115

Last 30 days Overall leaderboard