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
October Events

Mark Your Calendars

So many events that are happening this month - don't miss out!

Ignite 2022

WHAT’S NEXT AT MICROSOFT IGNITE 2022

Explore the latest innovations, learn from product experts and partners, level up your skillset, and create connections from around the world.

Power Apps Africa Challenge 2022

Power Apps Africa Challenge

Your chance to join an engaging competition of Power Platform enthusiasts.

Top Solution Authors
Top Kudoed Authors
Users online (3,070)