cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Anonymous
Not applicable

Sorting on text field on predefined order

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

3 ACCEPTED SOLUTIONS

Accepted Solutions
cyarbrough
Helper III
Helper III

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.

View solution in original post

v-xida-msft
Community Support
Community Support

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 Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

Anonymous
Not applicable

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

View solution in original post

5 REPLIES 5
cyarbrough
Helper III
Helper III

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.

View solution in original post

v-xida-msft
Community Support
Community Support

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 Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

Anonymous
Not applicable

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

Anonymous
Not applicable

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

 

 

Anonymous
Not applicable

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

View solution in original post

Helpful resources

Announcements
PA_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

Power Query PA Forum 768x460.png

Check it out!

Did you know that you can visit the Power Query Forum in Power BI and now Power Apps

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

R2 (Green) 768 x 460px.png

Microsoft Dynamics 365 & Power Platform User Professionals

DynamicsCon is a FREE, 4 half-day virtual learning experience for 11,000+ Microsoft Business Application users and professionals.

Users online (1,320)