web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / People pickers gallery...
Power Apps
Answered

People pickers gallery filter

(0) ShareShare
ReportReport
Posted on by 21

Hello.

 

I am building an app whose data source is a SharePoint list. On this SharePoint list i have 2 Person/Group columns ("Requerente" and "Projetista Responsável").

 

On my power apps application i am employing a gallery and i was planning on filtering its shown items based on the persons picked for both "Requerente" and "Projetista Responsável" options. So for each of those options i made a "me" checkbox (it gets the current user's email and compares it) and then i added another checkbox to enable the people pickers i got from an edit form that allow me to filter for another person.

Screenshot 2022-12-10 at 01-42-39 Power Apps.png

 

 

 

 

The code i wrote on the gallery's items property was:

 

Filter('Gestão de Ordens de Produção',
((Checkbox1.Checked && 'Projetista Responsável'.Email = User().Email) || Checkbox1.Checked = false && Checkbox2.Checked=false) || (Checkbox2.Checked && 'Projetista Responsável'.Email = DataCardValue1.Selected.Email) &&

((Checkbox3.Checked && Requerente.Email = User().Email) || Checkbox3.Checked = false && Checkbox4.Checked=false) || (Checkbox4.Checked && Requerente.Email = DataCardValue2.Selected.Email)
 )

 

"Gestão de Ordens de Produção" being the name of my SharePoint list.

 

The problem is that i cant get both filters to work at the same time. Using the code above, it only allows me to correctly filter based on the "Projetista Responsável" filter (The "Requerente" filter wont filter anything at all). But if i comment that first part of the code and disable the "Projetista Responsável" filter, the "Requerente" filter will work fine. But they won't function simultaneously.

 

I would appreciate any guidance on what can do to fix this problem

Categories:
I have the same question (0)
  • Verified answer
    cha_cha Profile Picture
    4,932 Moderator on at

    Hello @Lourenço 

     

    Please try replacing this && below with a comma and let me know how it goes.

    cha_cha_0-1670642875650.png

     

  • WarrenBelz Profile Picture
    153,073 Most Valuable Professional on at

    Hi @Lourenço ,

    Your main issue is proper bracketing and also you do not need to infer the negative value as it simply will not filter if at least one box is checked.

    Filter(
     'Gestão de Ordens de Produção',
     (
     (
     Checkbox1.Checked && 
     'Projetista Responsável'.Email = User().Email
     ) || 
     (
     Checkbox2.Checked && 
     'Projetista Responsável'.Email = DataCardValue1.Selected.Email
     )
     ) &&
     (
     (
     Checkbox3.Checked && 
     Requerente.Email = User().Email
     ) || 
     (
     Checkbox4.Checked && 
     Requerente.Email = DataCardValue2.Selected.Email
     )
     )
    )

     

    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.

    MVP (Business Applications)   Visit my blog Practical Power Apps

  • WarrenBelz Profile Picture
    153,073 Most Valuable Professional on at

    Hi @Lourenço ,

    I am intrigued how a comma fixed it as && and , mean the same thing in a Filter unless I am missing something.

  • Lourenço Profile Picture
    21 on at

    Hey @WarrenBelz ,

     

    I am definitely not the best person to explain what difference does it make between using a "&&" and a "," in this context but, truth be told, after that replacement the app works as intended and i can now use both filters at the same time.

     

    Perhaps @cha_cha could explain the reason why it works with a comma but not with &&?

  • WarrenBelz Profile Picture
    153,073 Most Valuable Professional on at

    Hi @Lourenço ,

    Thanks for the response - I was more focussed on condensing and fully bracketing your code than analysing fully what you had, but I have never used , in any filter (I know it works the same as &&, but prefer to see all my and/or with the same syntax)

  • cha_cha Profile Picture
    4,932 Moderator on at

    Hello  @Lourenço 

     

    EDIT: My response got mixed up upon submission

     

    I was gonna restructure your code but I found the 'plausible cause' when I was trying to break down the logic with your filter. 

    cha_cha_0-1670718711619.png

    Presuming A&B are ur rules for Projetista Responsáve (1st Filter) and C&D are your rules for Requerente (2nd Filter)

    If we translate it to a simple structure, this was your previous logic.

     

     Filter('Gestão de Ordens de Produção', A Or B And C Or D)

     

    The above structure results in something not you want because as long as condition A/D there results in True, it won't matter what B/C would result (this is an untested theory). 

     

    My initial thought was to correct your parenthesis structure and do something like the below: 

     

    Filter('Gestão de Ordens de Produção', (A Or B) And (C Or D)) 

     

     

    That would mean this if applied to the actual code:

    cha_cha_3-1670720714690.png

     

     

    But because of personal preference, I don't like too many parentheses, so, I suggested a comma, which does the same logic.Filter('Gestão de Ordens de Produção', A Or B, C Or D)

     

    Filter('Gestão de Ordens de Produção', A Or B,C Or D)

     

    I wasn't really fully sure what you were trying to achieve but the suggestion was based on evaluating your code.

     

    I don't have a clear explanation about commas in the filter function cause I just learned it that way.

     

    Here's full documentation about the filter and it says that a comma does the same thing as And (&&).

    https://learn.microsoft.com/en-us/power-platform/power-fx/reference/function-filter-lookup 

     

    cha_cha_2-1670719920748.png

     

  • WarrenBelz Profile Picture
    153,073 Most Valuable Professional on at

    Thanks @cha_cha ,

    This bit

    WarrenBelz_0-1670722318191.png

    confirms my understanding (as I mentioned I have never used commas)

     

     

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 721 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 320 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard