cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
bsamms
Frequent Visitor

Gallery Sorting & Filtering w/ numerous conditions

Despite trying to implement somewhat similar other examples for the forum, I have been unable to properly script the gallery display so that it sorts properly.  I've labeled a screenshot for clarification, and would appreciate the help of those of you who have a solid grasp on scripting:

pa_help.png

The current Items property of the gallery, which does work for merely displaying the cases in proper order and allows for searching from both TextSearchBox(es) is:
  Sort(
  Filter(
  [@CaseTracker_data],
  StartsWith('Employee Last Name',TextSearchBox1.Text),
  StartsWith('Employee ID',TextSearchBox2.Text)),
  CaseNumber, If(!SortDescending1, Descending, Ascending)
  )

However, I also need to be able to sort it specifically by CaseType, which is determined by a Choice, and has a value of either "A", "R", or "M".  I've created buttons which set a variable "varSortCases" to either "AA", "RDP", or "MISC", which correspond to the CaseType values.  Anytime I've attempted to adjust the gallery sort script above to include "if" statements, everything falls apart. 

I need the gallery, when varSortCases is "AA" to only display cases which have a CaseType value of "A", when varSortCases is "RDP" to only display cases which have a CaseType value of "R", and when varSortCases is "MISC" to only display cases which have a CaseType value of "M", along with the already functioning TextBoxSearch(es) and still sorting by CaseNumber when the varSortCases is in it's default "NONE" status.  I appreciate the time reviewing all of this and any help someone can provide.

 

1 REPLY 1
PowerAddict
Super User II
Super User II

Hi @bsamms 

 

Do you have an example of what you have tried? Does something like this not work? 

 

  Sort(
  Filter(
  [@CaseTracker_data],
  Case = varSortCases,
  StartsWith('Employee Last Name',TextSearchBox1.Text),
  StartsWith('Employee ID',TextSearchBox2.Text)),
  CaseNumber, If(!SortDescending1, Descending, Ascending)
  )

 

where I am assuming that Case is the name of the case field on CaseTracker_data. 

 

Let me know if this helps. 

 

---
If you like this reply, please give kudos (Thumbs Up). And if this solves your problem, please mark this reply as a solution by selecting Accept as Solution. This makes it easier for others to find answers to similar questions. 

 

Thanks!

Hardit Bhatia

Microsoft Business Applications MVP

Blog | Twitter | LinkedIn | Facebook | YouTube  |  Email

Helpful resources

Announcements
PA_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

Power Query PA Forum 768x460.png

Check it out!

Did you know that you can visit the Power Query Forum in Power BI and now Power Apps

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

PowerPlatform 768x460.png

Microsoft Learn

Check out our new Discover Your Career Path blog post series and get all the details.

Users online (1,811)