cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
DS2
Level 8

Want to use Sort first and then Filter

HI All,

I have a gallery that I filter on through a search box. I would like the gallery to have a default sort order, though. The filter works just fine:

If(ddlSearchType.Selected.Value = "Customer Name", Filter('SharePointDataSource', txtSearch.Text in Customer_x0020_Name ), ddlSearchType.Selected.Value = "Resolved Status", Filter('SharePointDataSource', txtSearch.Text in Resolved.Value),ddlSearchType.Selected.Value = "Corporate Account Manager", Filter('SharePointDataSource', txtSearch.Text in CAM_x0020_on_x0020_Account.Value), ddlSearchType.Selected.Value = "Invoice Number", Filter('SharePointDataSource', txtSearch.Text in Invoice_x0020_Number), ddlSearchType.Selected.Value = "Regional Director", Filter('SharePointDataSource', txtSearch.Text in Regional_x0020_Director.Value), ddlSearchType.Selected.Value = "Working Status", Filter('SharePointDataSource', txtSearch.Text in Working_x0020_Status.Value), ddlSearchType.Selected.Value = "Account Coordinator", Filter('SharePointDataSource', txtSearch.Text in A_x002f_C.Value))

However, I'd like to sort first by Account Coordinator (A_x002f_C.Value) in ascending and when I try to add a Sort field to the front of the expression, I get errors. How can I add Sort to the expression above so I can Sort and then Filter?

 

1 ACCEPTED SOLUTION

Accepted Solutions
DS2
Level 8

Re: Want to use Sort first and then Filter

Hi,

 

I just want to sort by one column, but also to use the filter. I'd like it to sort by that one column and then filter, but when I try to add sort I get errors. I've added Sort to the beginning of the filter and then the value and ascending to the end, as so:

Sort(If(ddlSearchType.Selected.Value = "Customer Name", Filter('Universal Dispute Log', txtSearch.Text in Customer_x0020_Name ), ddlSearchType.Selected.Value = "Resolved Status", Filter('Universal Dispute Log', txtSearch.Text in Resolved.Value),ddlSearchType.Selected.Value = "Corporate Account Manager", Filter('Universal Dispute Log', txtSearch.Text in CAM_x0020_on_x0020_Account.Value), ddlSearchType.Selected.Value = "Invoice Number", Filter('Universal Dispute Log', txtSearch.Text in Invoice_x0020_Number), ddlSearchType.Selected.Value = "Regional Director", Filter('Universal Dispute Log', txtSearch.Text in Regional_x0020_Director.Value), ddlSearchType.Selected.Value = "Working Status", Filter('Universal Dispute Log', txtSearch.Text in Working_x0020_Status.Value), ddlSearchType.Selected.Value = "Account Coordinator", Filter('Universal Dispute Log', txtSearch.Text in A_x002f_C.Value)),A_x002f_C.Value, Ascending)

However, I get errors with this and it is probably something I'm missing!

View solution in original post

3 REPLIES 3
emh
Level 8

Re: Want to use Sort first and then Filter

Hello,

 

Have you tried embedding the Sort function? The Sort function works on one column at a time. So to sort on 2 columns (CustomerNumber and OrderDate in the Orders table), the following would work:

 

Sort( Sort( Orders, CustomerNumber ), OrderDate )

 

Hope this helps.

DS2
Level 8

Re: Want to use Sort first and then Filter

Hi,

 

I just want to sort by one column, but also to use the filter. I'd like it to sort by that one column and then filter, but when I try to add sort I get errors. I've added Sort to the beginning of the filter and then the value and ascending to the end, as so:

Sort(If(ddlSearchType.Selected.Value = "Customer Name", Filter('Universal Dispute Log', txtSearch.Text in Customer_x0020_Name ), ddlSearchType.Selected.Value = "Resolved Status", Filter('Universal Dispute Log', txtSearch.Text in Resolved.Value),ddlSearchType.Selected.Value = "Corporate Account Manager", Filter('Universal Dispute Log', txtSearch.Text in CAM_x0020_on_x0020_Account.Value), ddlSearchType.Selected.Value = "Invoice Number", Filter('Universal Dispute Log', txtSearch.Text in Invoice_x0020_Number), ddlSearchType.Selected.Value = "Regional Director", Filter('Universal Dispute Log', txtSearch.Text in Regional_x0020_Director.Value), ddlSearchType.Selected.Value = "Working Status", Filter('Universal Dispute Log', txtSearch.Text in Working_x0020_Status.Value), ddlSearchType.Selected.Value = "Account Coordinator", Filter('Universal Dispute Log', txtSearch.Text in A_x002f_C.Value)),A_x002f_C.Value, Ascending)

However, I get errors with this and it is probably something I'm missing!

View solution in original post

DS2
Level 8

Re: Want to use Sort first and then Filter

It is now working, sorry about that! 

Helpful resources

Announcements
thirdimage

Power Automate Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

sixthImage

Power Platform World Tour

Find out where you can attend!

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

fifthimage

Microsoft Learn

Learn how to build the business apps that you need.

Top Kudoed Authors (Last 30 Days)
Users online (4,330)