cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
FelipeLeite
Helper I
Helper I

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

@FelipeLeite 

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!

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!

Microsoft Ignite 768x460.png

Find your focus

Explore the latest tools,training sessions,technical expertise, networking and more.

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

Welcome Super Users.jpg

Super User Season 2

Congratulations, the new Super User Season 2 for 2021 has started!

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

Users online (2,360)