cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
RickPeaugh
New Member

SortByColumns with custom sort in Filter does not work in DataTable

I have a DataTable with the following function in Items:

 

SortByColumns(
Filter(Eng_Apps_1, OS = Gallery1.Selected.'Operating System'),
"Application", Ascending, "Application Environment", Ascending)

 

The above works, but what I want is:

 

SortByColumns(
Filter(Eng_Apps_1, OS = Gallery1.Selected.'Operating System'),
"Application", Ascending, "Application Environment", ["Dev", "Staging", "Prod"])

 

And PowerApps says there is an error in the formula.  Can this be fixed or is there a workaround?

1 ACCEPTED SOLUTION

Accepted Solutions
rubin_boer
Super User
Super User

 @RickPeaugh may i suggest you add another column to your datasource and filet it by that column

SortByColumns(
AddColumns(
Filter(Eng_Apps_1, OS = Gallery1.Selected.'Operating System'),"AppEnvId",
Switch(true, "Application Environment" = "Dev", 1, "Application Environment" = "Staging", 2 ,3
),
"Application", Ascending, "AppEnvId", Ascending)

 

hope it helps

hey there if you liked the post give it a thumbs up, and if it solved your question please accept it as a solution.

View solution in original post

2 REPLIES 2
rubin_boer
Super User
Super User

 @RickPeaugh may i suggest you add another column to your datasource and filet it by that column

SortByColumns(
AddColumns(
Filter(Eng_Apps_1, OS = Gallery1.Selected.'Operating System'),"AppEnvId",
Switch(true, "Application Environment" = "Dev", 1, "Application Environment" = "Staging", 2 ,3
),
"Application", Ascending, "AppEnvId", Ascending)

 

hope it helps

hey there if you liked the post give it a thumbs up, and if it solved your question please accept it as a solution.

Ok.  That works. 🙂

Helpful resources

Announcements
Microsoft 365 Conference – December 6-8, 2022

Microsoft 365 Conference – December 6-8, 2022

Join us in Las Vegas to experience community, incredible learning opportunities, and connections that will help grow skills, know-how, and more.

Top Solution Authors
Top Kudoed Authors
Users online (1,441)