cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Advocate III
Advocate III

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

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

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.

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

Advocate III
Advocate III

It is now working, sorry about that! 

Helpful resources

Announcements
News & Announcements

Community Blog

Stay up tp date on the latest blogs and activities in the community News & Announcements.

Power Apps Community Call

Power Apps Community Call- January

Mark your calendars and join us for the next Power Apps Community Call on January 20th, 8a PST

PP Bootcamp Carousel

Global Power Platform Bootcamp

Dive into the Power Platform stack with hands-on sessions and labs, virtually delivered to you by experts and community leaders.

secondImage

Power Platform Community Conference On Demand

Watch Nick Doelman's session from the 2020 Power Platform Community Conference on demand!

Top Solution Authors
Top Kudoed Authors
Users online (6,896)