cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Australe
Frequent Visitor

Filter Gallery w/ UpdateContext Variable

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.

1 ACCEPTED SOLUTION

Accepted Solutions
HenriDesmet59
Super User
Super User

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

View solution in original post

5 REPLIES 5
HenriDesmet59
Super User
Super User

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
Super User
Super User

@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.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

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?

 

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.

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))

 

Helpful resources

Announcements
Super User 2 - 2022 Congratulations 768x460.png

Welcome Super Users

The Super User program for 2022 - Season 2 has kicked off!

Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

<
Users online (2,553)