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 / Filter Gallery w/ Upda...
Power Apps
Answered

Filter Gallery w/ UpdateContext Variable

(0) ShareShare
ReportReport
Posted on by 27

I'm learning PowerApps as I'm going along. Our company is in progress of onboarding to Office 365. I'm working on building out a Phone Directory that will pull from Office365Users connection. 
On one of the screens I'd like to provide a list of various departments(buttons) on the left pane, and on the right pane a gallery showing the filtered users by Dept. I would like to have All show us the entire list of enabled accounts. (Please see attached screenshot)

I think I'm on the right track, I stuck how to have the filter search by the local variable I'm setting with UpdateContext. Thoughts?

 

Is it possible to have 1 button search 'IT' and 'Information Technology'? 

 

Thank you in advance.

2022-03-30 17 26 10.jpg
Categories:
I have the same question (0)
  • Verified answer
    HenriDesmet59 Profile Picture
    295 on at

    Hello @Australe 

     

    Yes what you can do is to add after the "Account enabled" Filter the filter for department : 

    IsBlank(_searchDept) || department = _searchDept

     

    If the _searchDept is blank, then It will not filter on It. If not, It will filter on It.

     

    Tell me if It's helps you 🙂

     

    Henri

  • RandyHayes Profile Picture
    76,299 Super User 2024 Season 1 on at

    @Australe 

    My suggestion to you is to get rid of all the individual buttons on the left and replace with a Gallery (let's call it galDepartments).  Then add one button to the gallery.

    Set the Items property of the Gallery to: ["All", "Administration", "IT", ..etc..]

    Set the Text property of your label to: ThisItem.Value

     

    Then set the Items property of your right gallery to:

     

    Filter(
     Office365Users.SearchUserV2({top:500}).value,
     accountEnabled &&
     ((galDepartments.Selected.Value = "All") ||
     department = galDepartments.Selected.Value )
    )

     

     

    I hope this is helpful for you.

     

    EDIT: Forgot the accountEnabled...it is corrected in the above formula.

  • Australe Profile Picture
    27 on at

    That's wonderful! Thank you for this assistance!!

    Do you think it's possible to set two search terms on the UpdateContext? 
    For instance, IT and Information Technology on the same button?

     

  • HenriDesmet59 Profile Picture
    295 on at

    Yes it's possible, I think you can replace the variable UpdateContext by a ClearCollect to create a collection.

    Then in your filter you can write something like this : 

     

    IsEmpty(Col_Dep) || department in Col_Dep

     

    And when you select the All button you just Clear() the collection.

  • Australe Profile Picture
    27 on at

    Thanks for your reply. I played around and was able to get it to work by setting 2 variables on the button

    UpdateContext({_searchDept:"Information Technology", _searchDept2:"IT"})

    And using this for the Gallery

    Filter(Office365Users.SearchUser({top:500}), AccountEnabled = true, (IsBlank(_searchDept) || Department=_searchDept) || (IsBlank(_searchDept2) || Department=_searchDept2))

     

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 Launch!

Jump in, show your community spirit, and win prizes!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the May Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
Valantis Profile Picture

Valantis 395

#2
WarrenBelz Profile Picture

WarrenBelz 352 Most Valuable Professional

#3
Kalathiya Profile Picture

Kalathiya 287 Super User 2026 Season 1

Last 30 days Overall leaderboard