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 Apps / Sorting on text field ...
Power Apps
Answered

Sorting on text field on predefined order

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

Hi,

I want to apply sorting on text field by predefined order and not by alphabetically. 

Is it possible and how it is implemented in Power apps.

 

Thanks,

Pankaj

Categories:
I have the same question (0)
  • Verified answer
    cyarbrough Profile Picture
    72 on at

    can you explain the text field you're trying to sort on and how you want to sort it?

     

    you can probably use SortByColumns to do this. documentation here.

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

    Hi @Anonymous,

     

    Could you please share a bit more about your scenario?

    Do you want to sort your records based on text field (by predefined order) rather than by alphabetically?

    Further, do you use the SortByColumns function within your app?

     

    I suppose that you use the SortByColumns function within your app, is it true?

     

    If you use the SortOrder.Ascending or the SortOrder.Descending as the sort order within your SortByColumns function, your records would be sorted by alphabetically.

     

    You could also take a try to customize your soft order within your SortByColumns function. The SortByColumns function could sort based on a single column table of values, e.g. you can sort record based on the name of a day of the week by supplying [ "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday" ] as the sort order. All records which have Monday" will come first, followed by Tuesday, and so on.

     

    The formula format of above scenario as below:

    SortByColumns( Table, ColumnName, ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"])

    The standard formula format as below:

    SortByColumns( Table, ColumnName, SortOrderTable)
    

    On your side, you should type the following formula:

    SortByColumns( Table, TextField, ["text1","text2","text3",...])

     

    More details about the SortByColumns function in PowerApps, please check the following article:

    SortByColumns function

     

     

    Best regards,

    Kris

     

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Thanks Kris, this is exactly what i want

     

    I am not able to add the Sortbycolumn in my expression having filter function can you please help me with it, 

    Below is the expression i am using : 

     

    If(Dropdown1.Selected.Value = "All";Distinct(Filter('[dbo].[TableName]';Assignedto<>"All");Status);Distinct(Filter('[dbo].[Tablename]';Assignedto = Dropdown1.Selected.Value);Status))

     

    Where i need to apply SortBycolumn on below statement with predifined Status Order as  ["New";"Reallocated";etc..] 

     

    Distinct(Filter('[dbo].[TableName]';Assignedto<>"All");Status)

    Distinct(Filter('[dbo].[Tablename]';Assignedto = Dropdown1.Selected.Value);Status)

     

     

    Thanks Again. 

    Pankaj

     

     

     

     

    Thanks,

    Pankaj

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Thanks Kris, this is exactly what i want

     

    I am not able to add the Sortbycolumn in my expression having filter function can you please help me with it, 

    Below is the expression i am using : 

     

    If(Dropdown1.Selected.Value = "All";Distinct(Filter('[dbo].[TableName]';Assignedto<>"All");Status);Distinct(Filter('[dbo].[Tablename]';Assignedto = Dropdown1.Selected.Value);Status))

     

    Where i need to apply SortBycolumn on below statement with predifined Status Order as  ["New";"Reallocated";etc..] 

     

    Distinct(Filter('[dbo].[TableName]';Assignedto<>"All");Status)

    Distinct(Filter('[dbo].[Tablename]';Assignedto = Dropdown1.Selected.Value);Status)

     

     

    Thanks Again. 

    Pankaj

     

     

  • Verified answer
    Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Thanks all, I managed to add SortBycolumn within expression.

     

    If(Dropdown1.Selected.Value = "All";Distinct(SortByColumns(Filter('Table Name';Assignedto<>"All");"Status";["New";"Reallocated";etc..]);Status);Distinct(Filter('Table Name';Assignedto = Dropdown1.Selected.Value);Status))

     

     

    Thanks,

    Pankaj

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

Congratulations to the July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 429 Most Valuable Professional

#2
11manish Profile Picture

11manish 191 Super User 2026 Season 2

#3
MS.Ragavendar Profile Picture

MS.Ragavendar 122 Super User 2026 Season 2

Last 30 days Overall leaderboard