cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Eihab
Level: Power Up

Help with Search and Filters

Hi All, 

 

I am new to PowerApps and looking to use the the People screen for a directory in my workplace. I customized and it is looking good. However our O365 have many sister companies so the search is looking through all of the records. how can I make it look only into values where a condition is true for example only when companyname = ABC 

 

Do I change something here If(!IsBlank(Trim(TextSearchBox2.Text)), Office365Users.SearchUser({searchTerm: Trim(TextSearchBox2.Text) , top: 15})) This is the search results gallery Items value. 

 

I tried few things but not managing to fix it, hope you can help.

 

Thanks

Eihab 

1 ACCEPTED SOLUTION

Accepted Solutions
Community Support Team
Community Support Team

Re: Help with Search and Filters

Hi @Eihab ,

Do you want to filter your search results based on some conditions?

 

Based on the needs that you mentioned, I think the Filter function could achieve your needs. I have made a test on my side, please consider take a try with the following workaround:

Set the Items property of the Gallery to following:

 

If(
   !IsBlank(Trim(TextSearchBox2.Text)), 
    Filter(
             Office365Users.SearchUser({searchTerm: Trim(TextSearchBox2.Text) , top: 15}),
             CompanyName = "ABC"           // Type your Filter condition here
    )
) 

 

Please consider take a try with above solution, then check if the issue is solved.

 

The all avaiable properties which could be used as Filtered column in above formula, please refer to the following article:

https://docs.microsoft.com/en-us/powerapps/maker/canvas-apps/connections/connection-office365-users#...

 

Best regards,

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

3 REPLIES 3
Super User
Super User

Re: Help with Search and Filters

@Eihab 

Assuming this is your original code...

If(
    !IsBlank(Trim(TextSearchBox2.Text)),
    Office365Users.SearchUser({searchTerm: Trim(TextSearchBox2.Text),top: 15})
) 

 

...I think this could be achieved by applying a FILTER to ensure the email domain matches "@yourcompanyname.com"

 

If(
    !IsBlank(Trim(TextSearchBox2.Text)),
    Filter(
        Office365Users.SearchUser({searchTerm: Trim(TextSearchBox2.Text),top: 15}),
        "@yourcompanyname.com" in Mail
    )
) 

 

This approach worked when I tested it.  Please let me know if it works for you.

 

---
Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."

Community Support Team
Community Support Team

Re: Help with Search and Filters

Hi @Eihab ,

Do you want to filter your search results based on some conditions?

 

Based on the needs that you mentioned, I think the Filter function could achieve your needs. I have made a test on my side, please consider take a try with the following workaround:

Set the Items property of the Gallery to following:

 

If(
   !IsBlank(Trim(TextSearchBox2.Text)), 
    Filter(
             Office365Users.SearchUser({searchTerm: Trim(TextSearchBox2.Text) , top: 15}),
             CompanyName = "ABC"           // Type your Filter condition here
    )
) 

 

Please consider take a try with above solution, then check if the issue is solved.

 

The all avaiable properties which could be used as Filtered column in above formula, please refer to the following article:

https://docs.microsoft.com/en-us/powerapps/maker/canvas-apps/connections/connection-office365-users#...

 

Best regards,

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

Eihab
Level: Power Up

Re: Help with Search and Filters

Thank you so much for the help. This worked like a charm 🙂

 

If(
!IsBlank(Trim(TextSearchBox2.Text)),
Filter(
Office365Users.SearchUser({searchTerm: Trim(TextSearchBox1.Text) , top: 15}),
CompanyName = "Name" // Type your Filter condition here
)
)

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 (Last 30 Days)
Users online (5,895)