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.

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.
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

Helpful resources

Announcements
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

365 EduCon 768x460.png

Microsoft 365 EduCon

Join us for two optional days of workshops and a 3-day conference, you can choose from over 130 sessions in multiple tracks and 25 workshops.

Users online (3,361)