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 / Directory Search by Di...
Power Apps
Unanswered

Directory Search by Display Name and Department Name

(0) ShareShare
ReportReport
Posted on by 54

Hi, I created a directory and would like to search by department and display name when searching. In addition, exclude users who don't have a department name. The script below works but doesn't search by the department as well.

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

 

So I tried the one below but it has now filtered most of my users but I only want to filter the ones who don't have a department.

 

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

 

Categories:
I have the same question (0)
  • v-bofeng-msft Profile Picture
    Microsoft Employee on at

    Hi @bgreen1 ,

     

     

    I'm not quite sure if you want someone who has a department name or someone who doesn't. According to the second formula you provided, you will get all the people who have department names and then search for their department names and DisplayNames.

    vbofengmsft_0-1672800502672.png

    If you mean to filter by department name if the person has a department name, and filter by DisplayName if there is no department name, then the formula be:

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

     

    Best Regards,
    Bof

  • bgreen1 Profile Picture
    54 on at

    Hi Bof,

     

    Yes I want to be able to search someone who has a department name and displayname. For example if I search Information Technology everyone in information technology names will display. Also, if I search last name green evertyone last name green will show. Also, I want to set a filter if someone doesnt have a department name to exclude them. With the second formula when I search Information technology non of the employees display.

  • bgreen1 Profile Picture
    54 on at

    Yes correct,

     

    However,  the text below doesnt filter by DisplayName if there is no department name.

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

     

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the March Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 548

#2
WarrenBelz Profile Picture

WarrenBelz 408 Most Valuable Professional

#3
Haque Profile Picture

Haque 309

Last 30 days Overall leaderboard