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

Filter SQL table on multiple optional fields

Im trying to create a series of optional fields to filter my data source. 
I use check boxes to select the fields the user wish's to filter on.

MHackney_0-1599725890303.png

 

 

I am having trouble adding conditional filters however, I found a solution online which  doesn't work for me, it give's a delegation warning and fails to collect records.

 

ClearCollect(ArchiveSearch,Filter('[dbo].[Problems]',
If(ShowStatus.Value = false,true,FilterStatus.Selected.Result in Status) &&
If(ShowType.Value = false,true,FilterType.Selected.Type in Type) &&
If(ShowOwner.Value = false,true,FilterOwner.Selected.Result in Owner)))

 



Anyone have any suggestions how I can get this to work without having to write full filters for every possible combination of filter options which would be a couple of hundred lines long. 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Super User III
Super User III

Hi @MHackney ,

The non-delegable item is the in filter - it looks like you simply want them to equal

ClearCollect(
   ArchiveSearch,
   Filter('[dbo].[Problems]',
   If(
      ShowStatus.Value = false,
      true,
      Status=FilterStatus.Selected.Result
   ) &&
   If(
      ShowType.Value = false,
      true,
      Type=FilterType.Selected.Type
   ) &&
   If(
      ShowOwner.Value = false,
      true,
      Owner=FilterOwner.Selected.Result
   )
)

You are only ever going to get your Delegation limit anyway in the collection.

 

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

View solution in original post

2 REPLIES 2
Super User III
Super User III

Hi @MHackney ,

The non-delegable item is the in filter - it looks like you simply want them to equal

ClearCollect(
   ArchiveSearch,
   Filter('[dbo].[Problems]',
   If(
      ShowStatus.Value = false,
      true,
      Status=FilterStatus.Selected.Result
   ) &&
   If(
      ShowType.Value = false,
      true,
      Type=FilterType.Selected.Type
   ) &&
   If(
      ShowOwner.Value = false,
      true,
      Owner=FilterOwner.Selected.Result
   )
)

You are only ever going to get your Delegation limit anyway in the collection.

 

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

View solution in original post

Hmmm I had tried it with both equals and 'in'  with the same result, but direct copying your code seems to work correctly, Im not sure what was different but there must have been something slightly off.

Thank you very much for the help. 

Helpful resources

Announcements
secondImage

Experience what’s next for Power Apps

Join us for an in-depth look at the new Power Apps features and capabilities at the free Microsoft Business Applications Launch Event.

Power Apps Community Call

Power Apps Community Call: February

Did you miss the call? Check out the Power Apps Community Call here.

New Power Super Users

Congratulations!

We are excited to announce the Power Apps Super Users!

New Badges

New Solution Badges!

Check out our new profile badges recognizing authored solutions!

Top Solution Authors
Top Kudoed Authors
Users online (18,244)