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 / Powerapps Directory - ...
Power Apps
Answered

Powerapps Directory - Search DisplayName or Department

(0) ShareShare
ReportReport
Posted on by 54

How can I search my users via displayname or department with a created directory via powerapps? Using script below and it doesnt work. But dont want to include users in the search if they dont have a department name .

 

If(!IsBlank(Trim(TextSearchBox1.Text)), FirstN(Filter(Office365Users.SearchUser,(TextSearchBox1.Text in DisplayName || TextSearchBox1.Text in Department) top:999}),!IsBlank(Department)),15))

Categories:
  • v-qiaqi@microsoft.com Profile Picture
    Microsoft Employee on at

    Hi @bgreen1,

    Modify as below:

    If(
     !IsBlank(Trim(TextSearchBox1.Text)),
     FirstN(
     Filter(
     Office365Users.SearchUser(
     {
     searchterm: "",
     top: 999
     }
     ),
     !IsBlank(Department),
     (TextSearchBox1.Text in DisplayName || TextSearchBox1.Text in Department)
     ),
     15
     )
    )
  • bgreen1 Profile Picture
    54 on at

    Doesn’t work 😞

  • bgreen1 Profile Picture
    54 on at

    Does anyone know how a way to search by display name, job title, and/or department in the search box?

     
  • v-qiaqi@microsoft.com Profile Picture
    Microsoft Employee on at

    Hi @bgreen1,

    Tell me why it does not work, I could not imgine the error scenario.

    vqiaqimsft_0-1672976785547.png

    Hope you could provide the detailed error message so that others could help you figure it out.

  • bgreen1 Profile Picture
    54 on at

    It only limit the employees that are pulled for example when I search information technology only 3 members show. please see new note 4

     

    When I use  the script below . and Search Brandon Green the name shows with the department in information tech

     If(!IsBlank(Trim(TextSearchBox1.Text)), FirstN(Filter(Office365Users.SearchUser({searchTerm: Trim(TextSearchBox1.Text), top: 999}),!IsBlank(Department)),15))

     

  • Verified answer
    v-qiaqi@microsoft.com Profile Picture
    Microsoft Employee on at

    Hi @bgreen1,

    That does not mean "Doesn’t work".

    There's no way to search in the connector directly by the department - see https://docs.microsoft.com/connectors/office365users/ for a list of all operations on that connector. What you can do is to search users by some other field (such as name, for example), then use a Filter expression to only show the users for the search text related to department.

    vqiaqimsft_0-1672981682694.png

    You could find that you could only search by display name, UPN, and etc.

    The reason why you Search Brandon Green the name shows with the department in information tech is that the formula you provided only search use with the display name inlcuding Green, but not be responsible for the department.

     

    You use the same TextInput to search display or department, which will help you return the users with search text included in display name or department. As the screenshot I provided in my previous reply, I type S in the TextInput, which will return the users with S included in display name or in department name.

     

    Hope you could check the Office365Users() from the link to investigate this function deeperly.

     

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 248 Super User 2026 Season 2

#2
WarrenBelz Profile Picture

WarrenBelz 192 Most Valuable Professional

#3
Mohsin Ali Profile Picture

Mohsin Ali 135

Last 30 days Overall leaderboard