cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
MHackney
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
WarrenBelz
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
WarrenBelz
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
PA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

PA Community Call

Power Apps Community Call

Next call is happening on April 21st at 8a PST.

MBAS Carousel

Sign up for our May 4th event!

May the fourth be with you, join us online!

secondImage

Experience what’s next for Power Apps

See the latest Power Apps innovations, updates, and demos from the Microsoft Business Applications Launch Event.

Top Solution Authors
Top Kudoed Authors
Users online (44,021)