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

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
Advocate II
Advocate II

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
Highlighted
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
Advocate II
Advocate II

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

Highlighted
Advocate II
Advocate II

Re: Want to use Sort first and then Filter

It is now working, sorry about that! 

Helpful resources

Announcements
Check this Out

Helpful information

Featuring samples like Return to the Workplace and Emergency Response Applications

August 2020 Community Challenge: Can You Solve These?

August 2020 Community Challenge: Can You Solve These?

We're excited to announce our first cross-community 'Can You Solve These?' challenge!

secondImage

Return to Workplace

Reopen responsibly, monitor intelligently, and protect continuously with solutions for a safer work environment.

secondImage

Super Users Coming in August

We are excited for the next Super User season.

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

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