cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Anonymous
Not applicable

Filter City in Office365Users.SearchUser() function

Hi 🙂

I have a gallery that uses the Office365Users.SearchUser() function, but I don't want the gallery to show all employees. I want the gallery to show only employees where ThisItem.City = "TEK".

How can I insert this condition for City into my Office365Users.SearchUser() function?

1 ACCEPTED SOLUTION

Accepted Solutions

Use this mate, picking up on what @RandyHayes said:

 

Search(Office365Users.SearchUserV2({searchTerm:Trim(TextInput1.Text)}).value,TextInput2.Text, "City"))

 

On TextInput1 box you can search for a user's name, on TextInput2.Text you type TEK

 

This will give you the result you want. it will let you dynamically search for both user and city. Today you might want to search for TEK, but tomorrow you might need to search for something else. 

View solution in original post

5 REPLIES 5
RandyHayes
Super User
Super User

@Anonymous 

Please consider changing your Formula to the following:

Filter(Office365Users.SearchUserV2().value, city="TEK")

 

I hope this is helpful for you.

_____________________________________________________________________________________
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.
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

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

Do you want it hardcoded? Don't advise you to hardcode it. Add a second textinput box and then on the gallery put this:

 

Search(Office365Users.SearchUser({searchTerm: Trim(TextSearchBox1.Text), Top: 30}),TextInput2.Text,"City"))

 

This should do the trick

RandyHayes
Super User
Super User

@jbrit2020 

No, I'd not advise hard coding either.  Good suggestion if it is needed.

However, SearchUser is deprecated, please start using V2 to avoid issues going forward.

_____________________________________________________________________________________
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.
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

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

Hi, @RandyHayes 

I tried using this code, but it doesn't give me any data in the gallery.

However, if I use the function without any condition for City, the gallery brings me all the data.

Do you know what it can be?

Use this mate, picking up on what @RandyHayes said:

 

Search(Office365Users.SearchUserV2({searchTerm:Trim(TextInput1.Text)}).value,TextInput2.Text, "City"))

 

On TextInput1 box you can search for a user's name, on TextInput2.Text you type TEK

 

This will give you the result you want. it will let you dynamically search for both user and city. Today you might want to search for TEK, but tomorrow you might need to search for something else. 

View solution in original post

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

M365 768x460.jpg

Microsoft 365 Collaboration Conference | December 7–9, 2021

Join us, in-person, December 7–9 in Las Vegas, for the largest gathering of the Microsoft community in the world.

Top Solution Authors
Top Kudoed Authors
Users online (2,625)