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
jbrit2020
Continued Contributor
Continued Contributor

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.
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!
jbrit2020
Continued Contributor
Continued Contributor

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.
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!
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?

jbrit2020
Continued Contributor
Continued Contributor

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. 

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