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
Highlighted
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
Anonymous
Not applicable

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.

Highlighted
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
Better Together’ Contest Finalists Announced!

'Better Together’ Contest Finalists Announced!

Congrats to the finalists of our ‘Better Together’-themed T-shirt design contest! Click for the top entries.

thirdimage

Power Apps Community User Group Member Badge

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

sixthImage

Join THE global Microsoft Power Platform event series

Attend for two days of expert-led learning and innovation on topics like AI and Analytics, powered by Dynamic Communities

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

thirdimage

Microsoft Business Applications Virtual Launch

Join us for the Microsoft Business Applications Virtual Launch Event on Thursday, April 2, 2020, at 8:00 AM PST.

thirdimage

Community Summit North America

Innovate, Collaborate, Grow - The top training and networking event across the globe for Microsoft Business Applications

Top Solution Authors
Top Kudoed Authors
Users online (8,646)