cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Ptiwari
Level: Powered On

PowerApps office 365 search is not working for departments and job title

Hi,

We have created a PowerApps for our staff directory, added office 365 data connection on it.

When we searching user by name, it is showing correct result.

But when we tried to search by User department or job title ex: Accounting/HR. It is showing no results.

We are using below mentioned formula in our gallery.

Filter(Office365Users.SearchUser({searchTerm:TextInputEmp.Text}),!(IsBlank(Department)) && "companyname" in Lower(Mail))

I am not sure, why search is not working for department and job title. Please let me know if I need to make changes in my formula?

Any help is much appreciated.

Thanks

 

1 ACCEPTED SOLUTION

Accepted Solutions
Super User
Super User

Re: PowerApps office 365 search is not working for departments and job title

@Ptiwari 

Gotcha...thought there might be that situation when you were checking the company name.

So, set your formula to this:

Filter(Office365Users.SearchUser({top:500}), 
       !IsBlank(Department) && 
       "domain" in Mail &&
       (
           TextInputEmp.Text in DisplayName || 
           TextInputEmp.Text in Department || 
           TextInputEmp.Text in JobTitle
       )
  )

You can drop (as I did) the Lower statement.  When you use the In operator, it is case insensitive, so no need to use the lower or upper functions.

 

Also, if you want your list to show all results if nothing has been entered to "search" by, then consider this formula:

Filter(Office365Users.SearchUser({top:500}), 
       !IsBlank(Department) && 
       "domain" in Mail &&
       If(IsBlank(TextInputEmp.Text), true,
             (
               TextInputEmp.Text in DisplayName || 
               TextInputEmp.Text in Department || 
               TextInputEmp.Text in JobTitle
             )
      )
  )

 

 

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up. Solved your problem? - Click on Accept as Solution. Others seeking the same answers will be happy you did.

View solution in original post

11 REPLIES 11
Highlighted
Super User
Super User

Re: PowerApps office 365 search is not working for departments and job title

@Ptiwari 

Your formula will not be able to search title or department as you are using the SearchUser function.  The SearchTerm will only search display name, given name, surname, mail, mail nickname and user principal name.  

Please see the documentation on that function here.

 

I hope that explains for you the issue.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up. Solved your problem? - Click on Accept as Solution. Others seeking the same answers will be happy you did.
Ptiwari
Level: Powered On

Re: PowerApps office 365 search is not working for departments and job title

@RandyHayes Thank you for the quick reply.

Do you know the correct formula that search department, job title and display name?

Thanks

 

 

Super User
Super User

Re: PowerApps office 365 search is not working for departments and job title

@Ptiwari 

You would want to do that within your filter statement.

 

Filter(
     Office365Users.SearchUser(
          {searchTerm:TextInputEmp.Text}),
     !(IsBlank(Department)) && 
     "companyname" in Lower(Mail) && 
("whatever" in Department || "Whatever" in JobTitle) )

 

 

 

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up. Solved your problem? - Click on Accept as Solution. Others seeking the same answers will be happy you did.
Ptiwari
Level: Powered On

Re: PowerApps office 365 search is not working for departments and job title

@RandyHayes 

I have tried this formula but it is not showing any results.

It is showing 0 count in my search bar.

Thanks

Super User
Super User

Re: PowerApps office 365 search is not working for departments and job title

@Ptiwari 

Please share what your formula looks like at this point.  That will help to determine where the problem may be.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up. Solved your problem? - Click on Accept as Solution. Others seeking the same answers will be happy you did.
Ptiwari
Level: Powered On

Re: PowerApps office 365 search is not working for departments and job title

@RandyHayes 

Hi,

I have tried your formula again, it shows me a result but it is different than what I am looking.

What I am trying to do is,  create a search box that will search not only the user's name, but also search across other parameters like Job Tile and Department. So if someone types in Steve, they find all the Steves, but if they type in "market" all Marketing department members or anyone with "Market" in their title would pop up.

 

How could I search on other parameters besides the Display Name? please check the image below.

Thanks2019-06-28_9-27-00.jpg

 

Super User
Super User

Re: PowerApps office 365 search is not working for departments and job title

@Ptiwari 

So, if I understand the pop-out annotation on your picture, you want the users to be able to type in a name, or a department, or a title and have results appear.

The formula I supplied is fairly restrictive based on your previous formula.

The formula states to return any items that are found in the searchTerm  SearchUser({searchTerm: TextInputEmp.Text})  - THEN filter those results by department not being blank, the literal text "companyname" being in the Mail column and either the word "Marketing" being in Department or "Developer" being in JobTitle.

I believe that you ultimately want to replace the hard-coded "Marketing" and "Developer" in the formula to be the TextInputEmp.Text.

This will cause an issue.  If a user wants to search for "Marketing" as a department, the first restrictive aspect is the SearchUser function because here you are searching for "Marketing" in the columns that SearchUser will search (as previously mentioned in an earlier message).  This will return nothing and thus the rest of the filter formula will be irrelevant. 

I'm not really sure what "companyname" in the Mail has to do with your searching unless you are somehow dealing with multiple domains in your tenant.

So, based on the above, I would suggest the following formula for your Items property:

 

Filter(Office365Users.SearchUser(), 
TextInputEmp.Text in DisplayName ||
TextInputEmp.Text in Department ||
TextInputEmp.Text in JobTitle)

This will provide what appears to be your requirement in your picture annotation.

 

 

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up. Solved your problem? - Click on Accept as Solution. Others seeking the same answers will be happy you did.
Ptiwari
Level: Powered On

Re: PowerApps office 365 search is not working for departments and job title

@RandyHayes 

Yes, we are hosting multiple domain in our tenant. That's why I added company name in my previous formula (so that I can show only 1 domain results in my gallery). I modified your formula little bit, it started showing me results based on Department/Job Title/User Name. But it showing other domain users also in my gallery. Added screen shot also for the reference. Now I need to figure it out how can I show only 1 domain result in my gallery/search? Thank you so much for your help. I really appreciate that. Please let me know how can I search results just for single domain? 

 

2019-06-28_11-34-26.jpg

 

Super User
Super User

Re: PowerApps office 365 search is not working for departments and job title

@Ptiwari 

Gotcha...thought there might be that situation when you were checking the company name.

So, set your formula to this:

Filter(Office365Users.SearchUser({top:500}), 
       !IsBlank(Department) && 
       "domain" in Mail &&
       (
           TextInputEmp.Text in DisplayName || 
           TextInputEmp.Text in Department || 
           TextInputEmp.Text in JobTitle
       )
  )

You can drop (as I did) the Lower statement.  When you use the In operator, it is case insensitive, so no need to use the lower or upper functions.

 

Also, if you want your list to show all results if nothing has been entered to "search" by, then consider this formula:

Filter(Office365Users.SearchUser({top:500}), 
       !IsBlank(Department) && 
       "domain" in Mail &&
       If(IsBlank(TextInputEmp.Text), true,
             (
               TextInputEmp.Text in DisplayName || 
               TextInputEmp.Text in Department || 
               TextInputEmp.Text in JobTitle
             )
      )
  )

 

 

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up. Solved your problem? - Click on Accept as Solution. Others seeking the same answers will be happy you did.

View solution in original post

Helpful resources

Announcements
thirdimage

Power Automate Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

sixthImage

Power Platform World Tour

Find out where you can attend!

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

fifthimage

Microsoft Learn

Learn how to build the business apps that you need.

Top Kudoed Authors
Users Online
Currently online: 187 members 4,591 guests
Please welcome our newest community members: