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

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Filtering a gallery ba...
Power Apps
Answered

Filtering a gallery based on different scenarios

(0) ShareShare
ReportReport
Posted on by 163

Hi,

 

I have a gallery that I am trying to filter with different items depending on different scenarios but I can't quite get it to work correctly.

 

There is a variable called varAdmin that is set on start, and if that is True, I want the gallery to filter a column in SP called Phase where it is either Phase 1, 2, 3, 4, or 5, and the Status is NOT Rejected.

 

If varAdmin is False, it then needs to check if the User created the Items, and filter the gallery where the Created By column is the user logged in and the Phase column equals Phase 1 or 3, and the Status is NOT Rejected

 

The final scenario is where the current user is listed in a column called Manager and the Phase equals 1 and the status does NOT equal Rejected.

 

Below is my current formula but it doesn't seem to work correctly, any ideas?


If(varAdmin,
Filter(colAllItems,Phase="Phase 1"|| Phase="Phase 2"||Phase="Phase 3"||Phase="Phase 4"||Phase="Phase 5" && Status <> "Rejected"),
If(!varAdmin,
If(!IsBlank(LookUp(colAllItems, ('Created By'.Email = User().Email))),
Filter(colAllItems, ('Created By'.Email = User().Email)&& (Phase="Phase 1" || Phase = "Phase 3") && (Status <> "Rejected")),
Filter(colAllItems, (Manager = User().Email) && (Phase="Phase 1") && (Status <> "Rejected")))))

 

Categories:
  • v-jefferni Profile Picture
    Microsoft Employee on at

    Hi @lalford09 ,

     

    Could you please share more details about your scenario? What are the types of those columns you mention?

     

    Best regards,

  • lalford09 Profile Picture
    163 on at

    @v-jefferni

     

    Hi, they are single line of text, and Created By is an auto created field when a new item is created in the SP list

  • Verified answer
    v-jefferni Profile Picture
    Microsoft Employee on at

    Hi @lalford09 ,

     

    OK, I understand. Then first please create a variable for user Email OnStart of App to avoid delegation issue:

     

    Set(varUserEmail, User().Email)

     

     

    and now the formula may can be:

     

    With(
     {wNReject: Filter(colAllItems, Status <> "Rejected")},
     If(
     varAdmin,
     Filter(
     wNReject, Phase="Phase 1"|| Phase="Phase 2"||Phase="Phase 3"||Phase="Phase 4"||Phase="Phase 5"
     ),
     If(
     IsBlank(LookUp(wNReject, 'Created By'.Email = varUserEmail)),
     Filter(
     wNReject, Manager = varUserEmail && Phase="Phase 1"
     ),
     Filter(
     wNReject, 'Created By'.Email = varUserEmail && (Phase="Phase 1" || Phase = "Phase 3")
     )
     )
     )
    )

     

     

    Best regards,

  • lalford09 Profile Picture
    163 on at

    @v-jefferni Works perfectly! thank you!

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 248 Super User 2026 Season 2

#2
WarrenBelz Profile Picture

WarrenBelz 192 Most Valuable Professional

#3
Mohsin Ali Profile Picture

Mohsin Ali 135

Last 30 days Overall leaderboard