web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / How to search Office36...
Power Apps
Answered

How to search Office365Users by location or department?

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

The documentation for the SearchUser function states that it only applies to: display name, given name, surname, mail, mail nickname, and user principal name.

 

I want to design a PowerApp that will pull a list of all current Locations or Departments for users in my organization, and then list all users who work at that Location or Department. If the SearchUser function won't let me search by these fields, is there some other way to do it?

Categories:
  • Verified answer
    dinusc Profile Picture
    Microsoft Employee on at

     You should be able to use Filter function to filter the results of the Office365Users.SearchUser by Location or Department. The "catch" here is that this will work only if the number of users in your organiation does not exceed the maximum nuber of rows per connector. That value is 500 by default and it can be increased to up to 2000.

  • BitLord69 Profile Picture
    914 on at

    Might be increased I want to add. In some of my apps I tried changing the limit but then the apps stopped working; I  get a lot of error messages when trying to access the resources.

     

    Perhaps it is because I use views. Other than that I'm not doing anything out of the ordinary.

  • RHCC Profile Picture
    40 on at

    Hi @dinus, 

    I would be willing to try your idea, as several methods online have not worked thus far. Would you please care to elaborate on how you might execute something like this using the PowerApps platform? Thank you!

  • dinusc Profile Picture
    Microsoft Employee on at

    @RHCC, My suggestion was to provide a search string that would match all the users and then filter the search results: For example, let's say that you need to list all the users from all the departments that have the word "consult" in the name ("Consulting Department" for example). You could use something like the following:

    Filter(Office365Users.SearchUser({searchTerm:"."}), "consult" in Department)

    The "searchTerm" should evaluate to all the users since it also searches by emails and all the emails should contain "." (period).

    Please note that this should work in case the number of users in your organization is less than the maximum number of records pulled by connector (500 by default that can be increased up to 2,000)

     

    @BitLord69,

    I suspect that the crash after increasing the number of records is not related to views but rather to the amount of data pulled. This should be the case when the source that you use has many columns. My guess is that your device runs out of memory. 

  • RHCC Profile Picture
    40 on at

    Thanks for the quick response, @dinusc! However, I realize now that my problem is different than what is described here.

     

    I am trying to 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 Karen, they find all the Karens, but if they type in "market" all Marketing department members or anyone with "Market" in their title would pop up, even if it was a partial search.

     

    From what I understand, there are a few ways to filter search results, but how could I search on other parameters besides the Display Name? I may need to create my own post for this, and if so I can do that. Feel free to let me know what you recommend. Thank you!

  • dinusc Profile Picture
    Microsoft Employee on at
    Would not something line the following work? Filter(Office365Users.SearchUser({searchTerm:"."}), TextInput1.Text in Department Or TextInput1.Text in JobTitle)
  • Ptiwari Profile Picture
    42 on at

    @RHCC I am having same issue.

    Did you find any solution for this issue?

    Thanks

  • bhoyer Profile Picture
    6 on at

    Hey Ptiwari. New here. Did you ever find a solution for this? Thanks. 

  • RHCC Profile Picture
    40 on at

    Welp, never saw this. Busy life and all - my apologies. Anyways I was never able to figure this out, so instead...

    -----------

    Basically I just made a search bar looking at one value, Employee Name, then used a filter for the other parameter, department.

     

    - The page has a search bar and a drop down control at the top, then below is a gallery control.

     

    - "Search bar" is named 'inpSearchBar' in Power Apps

     

    - There is a Department dropdown. The Dropdown items are generated by using a collection, 'colDEPT', which is pulling the Department choices from the SharePoint list on app launch. I am using this in the Items property of the App Start to grab the department values to be used in the dropdown: ClearCollect(colDEPT,Choices('[SharePoint List]'.Department))

     

    - "Items" property on the gallery below it:
    SortByColumns(Filter('[SharePoint List]',StartsWith('Employee Name',inpSearchBar.Text),Department.Value=Dropdown1.Selected.Value),"Start Date",Ascending)

     

    - It may not be exactly what is asked for in this but figured I'd tie this loose end. I got a thing about loose ends 🙂

     

    If anybody ever has questions, please feel free to private message me. 

  • RHCC Profile Picture
    40 on at

    Hi there,

    I responded to Ptiwari, hope it helps you. Thanks for leaving a message, it caused me to see this 🙂

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 236 Super User 2026 Season 2

#2
WarrenBelz Profile Picture

WarrenBelz 207 Most Valuable Professional

#3
Mohsin Ali Profile Picture

Mohsin Ali 169

Last 30 days Overall leaderboard