cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
HuseyinAhmet
Level: Powered On

Multiple Filters not working?

Hello,

 

I am having an issue with the Filter method in powerapps, I would like to be able to have my app only display information based on a property inside one of my collums, I have a collum called type, and I am trying to make it so that clicking on certain buttons will filter my dataset so that only those things appear, here is an example of the code I am using:

 


If(SortPriority="NAME", SortByColumns (Search ('MyDataSet', TextSearchBox1.Text, "NAME","TYPE") , "NAME", If(SortDescending1, Descending,Ascending))

 

, If(SortPriority="QUICK", SortByColumns (Search ('MyDataSet', TextSearchBox1.Text, "NAME", "TYPE"), "TYPE", If(SortDescending2, Descending,Ascending)),

 

If(SortPriority="FIELD", Filter( Spells, "FIELD" in Lower(TYPE)), SortByColumns (Search (Spells, TextSearchBox1.Text, "NAME", "TYPE"), "TYPE", If (SortDescending3, Descending, Ascending)))))

 

As you can see I am actually using a filter, and it is working just how I would like it to, "FIELD" is a possible value in the "TYPE" collum, I would also like to be able to filter for the work "QUICK" in "TYPE" aswell, as you can see above all the second set of code does is return the whole "TYPE" list. When I attempt this however:

 


If(SortPriority="NAME", SortByColumns (Search ('MyDataSet', TextSearchBox1.Text, "NAME","TYPE") , "NAME", If(SortDescending1, Descending,Ascending))

 

, If(SortPriority="QUICK", Filter( Spells, "QUICK" in Lower(TYPE)), SortByColumns (Search ('MyDataSet', TextSearchBox1.Text, "NAME", "TYPE"), "TYPE", If(SortDescending2, Descending,Ascending)),

 

If(SortPriority="FIELD", Filter( Spells, "FIELD" in Lower(TYPE)), SortByColumns (Search (Spells, TextSearchBox1.Text, "NAME", "TYPE"), "TYPE", If (SortDescending3, Descending, Ascending)))))

 

The app stops working completely, explaining that there is an:
 Invalid Argument Type(Table).Expecting a Boolean value instead.

 

I am not entierly sure why this isnt working, if I should be doing something else or have made a simple mistake please let me know.

7 REPLIES 7
hpkeong
Level 10

Re: Multiple Filters not working?

Hi

 

I would suggest not to use so many nested IF, because when you have more and more FIELDS, it will become very complicated and not easy for editing in future.

 

Say you have TextBoxed with TITLES on top of Gallery. Please set the Sort function by OnSelect for each title using:

- UpdateContext({Sorta: !Sorta});

- Set the Gallery.Items = SourceSO (any variable name to represent the Gallery).

 

With this, you can set as many sorting criteria as you wish.

 

 

 

 

Otherwise, you can also use Dropdown.Selected.Value to filter in second screenschot.

 

Screenshot (51).png

 

Hope these help.

hpkeong
hpkeong
Level 10

Re: Multiple Filters not working?

Hi

 

As we have been discussing over another Post, and while awaiting someone else to resolve the numerical sorting issues (which I am also finding out WHY), I found that you are actually looking for multiple Sort.

 

So, my latest sharing of using TITLE and OnSELECT will be more proper for you.

It will be much more simpler and straightforward.

 

Please feel free to try it out.

hpkeong

Re: Multiple Filters not working?

Hi hpkeong,

 

I am interested in 

Gallery.Items = SourceSO

How do I bind multiple columns to gallery? If I put actual datasource in gallery items it shows columns to bind

 

I have multiple filter textboxes and dropdowns on which I want to filter the gallery(without using if statement in gallery items as it kills 500+ delegation)

hpkeong
Level 10

Re: Multiple Filters not working?

Hi @AmitLoh-Powerap

 

In PowerApps example (3-screens autogenerated apps), it always use

- Sortby(Search(.............. Filter(..........)) where the Gallery.Items = TableX

 

This is OK only for SINGLE Search!

 

But, I always prefer to have several ways of searching, such as:

- TextInput (as of MS example)

- Sort by Dropdown

- Sort All, Group, etc.

 

In this case, you have to use:

- Screen.OnVisible = ClearCollect(NewCollection, Filter(OriginalTable, Condition as you wish, ......)) if pre-filter needed, OR

                                  ClearCollect(NewCollection, OriginalTable)...If no pre-filter needed

- Set the Gallery.Items = NewCollection

 

Now you can have different kind of Seach, by always referring to this NewCollection.

e.g.:

1. ButtonAll.OnSelect = ClearCollect(NewCollection, OriginalTable)...whenver you want to revert back to view ALL

2. InputText1.OnSelect or OnChange = ClearCollect(NewCollection, If(IsBlank(TextInput1.Text), OriginalTable, Filter(OriginalTable, FieldTitleZ = InputText1.Text)))

3. DropDown.OnSelect or OnChange = ClearCollect(NewCollection, Filter(OriginalTable, FieldTitleX = or exactin or in Dropdown1.Selected.Result)), where the Dropdown can be Dropdown1.Items = Distinct(OriginalTable, FieldTitleX)

4. Others where the syntax is identifical of Dropdown.

 

You can observe here that: All Filtering, Dropdown, Input Text will eventually being ClearCollect ino NewCollection, where NewCollection is the items for Gallery.

 

Learn Tutorial has never mentioned this method because it assumes that most of the time, we only fitler ONE WAY, but the logic is the same. I am sure you are aware of this but never try or maybe I am wrong.

 

Hope this helps.

hpkeong
hpkeong
Level 10

Re: Multiple Filters not working?

Hi @HuseyinAhmet @AmitLoh-Powerap

 

Just sharing on the use of IF function (nothing to do with multi filter.. please see another post to @AmitLoh-Powerap).

 

Nested IF

If( Condition, Result [, ElseResult ] ) or

If( Condition, Result , If( Condition, Result, If( Condition1, Result1, If( ... [ , ElseResult ] ] )

 

The above is similar to EXCEL.

In PowerApps, when coming to more than one IF, please ignore Excel method, but use the following and it is much more simpler without SO MANY )))))).

NB:

With the use of Shift+Enter (as mentioned by @mr-dang), you can easily organized formual into different rows with better visual effect.

 

 - If( Condition1, Result1 [, Condition2, Result2, ... [ , ElseResult ] ] )

If(If( IsBlank( Slider1.Value ), "Result1", IsNumeric( Slider1.Value ), "Result2", Condtion3, "Result3", Conditon4, "Result4", .............., "ResultN" )

 

Hope this expedite formula writing with minimum error.

hpkeong

Re: Multiple Filters not working?

thanks!

ClearCollect(NewCollection, Filter(OriginalTable, Condition as you wish, ......))

Does this also handle 500+ scrolling because for me it stops at 500, I have 100 k items. If I use out of box one search then 500+ scroll works.

Re: Multiple Filters not working?

it does not support more than 500 and for me thats the problem although great solution! thanks!!

All other functions do not support delegation, including these notable functions:

Helpful resources

Announcements
thirdimage

Power Automate Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

sixthImage

Power Platform World Tour

Find out where you can attend!

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

fifthimage

Microsoft Learn

Learn how to build the business apps that you need.

Top Kudoed Authors (Last 30 Days)
Users online (4,876)