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

Odd behaviour when using Filter function within gallery items property

I'm having a bit of a nightmare with my gallery list filter query. I remember having the same issue a while back, but changed my logic to work around the issue at the time. Basically, I've got a conditional statement checking for a dropdown selection within the gallery. Depending on the selection, multiple other fields are used to determine the entries to return. The filters also consider the current user in relation to the gallery items and another permissions list.

 

The rough logic is as follows:

 

SortByColumns
(
    Switch
    (
        Dropdown1.Selected.Value,
        "Selection",
        If
        (
            value = "value"
            Filter
            (
                filter queries
                &&
                (
                    'Search box'.Text in field1value
                    || 'Search box'.Text in field2value
                )
            ),
            Filter
            (
                filter queries
                &&
                (
                    'Search box'.Text in field1value
                    || 'Search box'.Text in field2value
                )
            )
        )
    ),
    field3,Descending
)

 

 

The logic works fine when written as above. The problem comes when I try and change one of the filter statements to include an additional check - e.g. "filter queries" becomes "(value1 = "value" || filter queries)". The additional brackets seem to break the filter query (which can be seen by the help text changing from "Filter(source,logical_test,logical_test...)" to "If(logical_test,true_value...)".

 

It seems to think the filter statement is finished, even though I'm still within the brackets.

 

Am I missing something obvious?!

1 ACCEPTED SOLUTION

Accepted Solutions
Dual Super User
Dual Super User

Re: Odd behaviour when using Filter function within gallery items property

Hi @cattre 

 

Can you try to use And() and Or() function in case of multiple nested conditions?

Something like:
SortByColumns
(
Switch
(
Dropdown1.Selected.Value,
"Selection",
If
(
value = "value"
Filter
(
And(filter queries,Or( 'Search box'.Text in field1value,'Search box'.Text in field2value))
),
Filter
(
And(filter queries,Or( 'Search box'.Text in field1value,'Search box'.Text in field2value))
)
)),
field3,Descending
)

Also, there was a bracket mismatch in the expression, please make sure that you are closing the brackets appropriately.

 

Hope this Helps!

 

If this reply has answered your question or solved your issue, please mark this question as answered. Answered questions helps users in the future who may have the same issue or question quickly find a resolution via search. If you liked my response, please consider giving it a thumbs up. THANKS!

View solution in original post

2 REPLIES 2
Dual Super User
Dual Super User

Re: Odd behaviour when using Filter function within gallery items property

Hi @cattre 

 

Can you try to use And() and Or() function in case of multiple nested conditions?

Something like:
SortByColumns
(
Switch
(
Dropdown1.Selected.Value,
"Selection",
If
(
value = "value"
Filter
(
And(filter queries,Or( 'Search box'.Text in field1value,'Search box'.Text in field2value))
),
Filter
(
And(filter queries,Or( 'Search box'.Text in field1value,'Search box'.Text in field2value))
)
)),
field3,Descending
)

Also, there was a bracket mismatch in the expression, please make sure that you are closing the brackets appropriately.

 

Hope this Helps!

 

If this reply has answered your question or solved your issue, please mark this question as answered. Answered questions helps users in the future who may have the same issue or question quickly find a resolution via search. If you liked my response, please consider giving it a thumbs up. THANKS!

View solution in original post

cattre
Level: Powered On

Re: Odd behaviour when using Filter function within gallery items property

Thanks @yashag2255 - I just realised this myself actually! I was trying to separate the multiple filter queries inside the brackets with commas. I then tried using && and this worked.

 

I will probably tidy this up and use AND as you have suggested.

Helpful resources

Announcements
thirdimage

Power Apps Super User Class of 2020

Check it out!

thirdimage

New Badges

Check it out!

thirdimage

Power Apps 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

SecondImage

Difinity Conference

The largest Power BI, Power Platform, and Data conference in New Zealand

Top Solution Authors
Top Kudoed Authors
Users online (5,235)