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

Filter Gallery Items

Hey guys,

 

I have a PowerApp that filters employee within the company. There's some accounts from my Office365 that do not have a department.

When filtering, my dropdown has an empty item ([""]) which reads all departments, but I don't want the accounts with an empty department to be viewable within the gallery.

 

Is there any way of doing this?

 

Thanks in advance!

2 ACCEPTED SOLUTIONS

Accepted Solutions
SilvesterP
Level: Powered On

Re: Filter Gallery Items

Give this a crack? 

I'm assuming ddDepartment.Selected.Value <> "" was your first attempt to check if department value is blank.

Else just add it in as a new condition to your filter. 

 

Filter(

   Office365Users.SearchUser(
      {searchTerm:txtInputEmployee.Text, top: 500})
       , AccountEnabled = true,

       If(Len(ddDepartment.Selected.Value) > 0,

       Department = ddDepartment.Selected.Value,true)

)

View solution in original post

Andy_Prog
Level: Powered On

Re: Filter Gallery Items

Hi @SilvesterP,

 

I have found a solution using your solution:

Filter(
    Office365Users.SearchUser(
        {
            searchTerm: txtInputEmployee.Text,
            top: 500
        }
    ),
    AccountEnabled = true,
    If(
        Len(Department) < 1,
        Department = ddDepartment.Selected.Value,
        true
    ),
    If(
        ddDepartment.Selected.Value <> "",
        Department = ddDepartment.Selected.Value,
        true
    )
)

Thank you very much for the assistance, much apprciated!! Smiley Very Happy

View solution in original post

7 REPLIES 7
SilvesterP
Level: Powered On

Re: Filter Gallery Items

Hey Andy,

 

I would do a filter where the length of the department is not null. Filter(DataSource, Len(datasourcefield) > 0)

 

PowerAppCodeSnap.PNGExample

SilvesterP
Level: Powered On

Re: Filter Gallery Items

Hey Andy,

 

I would do a filter where the length of the department is not null. Filter(DataSource, Len(datasourcefield) > 0)

 

PowerAppCodeSnap.PNGExample

Andy_Prog
Level: Powered On

Re: Filter Gallery Items

Hi @SilvesterP ,

 

Thanks for your response.

 

How can I incorporate that function into this function for my Gallery:

Filter(Office365Users.SearchUser({searchTerm:txtInputEmployee.Text, top: 500}), AccountEnabled = true, If(ddDepartment.Selected.Value <> "",Department = ddDepartment.Selected.Value,true))

In the dropdown menu I have values in as ["","IT","Accounting",etc.]

 

Kind Regards,

 

Andy.

SilvesterP
Level: Powered On

Re: Filter Gallery Items

Give this a crack? 

I'm assuming ddDepartment.Selected.Value <> "" was your first attempt to check if department value is blank.

Else just add it in as a new condition to your filter. 

 

Filter(

   Office365Users.SearchUser(
      {searchTerm:txtInputEmployee.Text, top: 500})
       , AccountEnabled = true,

       If(Len(ddDepartment.Selected.Value) > 0,

       Department = ddDepartment.Selected.Value,true)

)

View solution in original post

Andy_Prog
Level: Powered On

Re: Filter Gallery Items

So I tried it, and I get the same result.

 

The accounts with Departments that are empty are still displaying.

But I used this and it shows only the accounts that have no department:

Filter(
Office365Users.SearchUser(
{searchTerm:txtInputEmployee.Text, top: 500}),
AccountEnabled = true,
If(Len(Department) > 0,
Department = ddDepartment.Selected.Value,true)
)

But I want to view the accounts that have a department in the Office365 contacts if you understand what I mean?

Sorry if it's a little confusing.

Andy_Prog
Level: Powered On

Re: Filter Gallery Items

So I tried it, and I get the same result.

 

The accounts with Departments that are empty are still displaying.

But I used this and it shows only the accounts that have no department:

Filter(
Office365Users.SearchUser(
{searchTerm:txtInputEmployee.Text, top: 500}),
AccountEnabled = true,
If(Len(Department) > 0,
Department = ddDepartment.Selected.Value,true)
)

But I want to view the accounts that have a department in the Office365 contacts if you understand what I mean?

Sorry if it's a little confusing @SilvesterP .

Andy_Prog
Level: Powered On

Re: Filter Gallery Items

Hi @SilvesterP,

 

I have found a solution using your solution:

Filter(
    Office365Users.SearchUser(
        {
            searchTerm: txtInputEmployee.Text,
            top: 500
        }
    ),
    AccountEnabled = true,
    If(
        Len(Department) < 1,
        Department = ddDepartment.Selected.Value,
        true
    ),
    If(
        ddDepartment.Selected.Value <> "",
        Department = ddDepartment.Selected.Value,
        true
    )
)

Thank you very much for the assistance, much apprciated!! Smiley Very Happy

View solution in original post

Helpful resources

Announcements
Better Together’ Contest Finalists Announced!

'Better Together’ Contest Finalists Announced!

Congrats to the finalists of our ‘Better Together’-themed T-shirt design contest! Click for the top entries.

thirdimage

Power Apps Community User Group Member Badge

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

sixthImage

Join THE global Microsoft Power Platform event series

Attend for two days of expert-led learning and innovation on topics like AI and Analytics, powered by Dynamic Communities

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

thirdimage

Microsoft Business Applications Virtual Launch

Join us for the Microsoft Business Applications Virtual Launch Event on Thursday, April 2, 2020, at 8:00 AM PST.

thirdimage

Community Summit North America

Innovate, Collaborate, Grow - The top training and networking event across the globe for Microsoft Business Applications

Top Solution Authors
Top Kudoed Authors
Users online (9,462)