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.

Highlighted
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
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 (4,693)