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)

)

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

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)

)

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

Helpful resources

Announcements
firstImage

Watch Sessions On Demand!

Continue your learning in our online communities.

SecondImage

Follow PowerApps on Twitter

Stay Up-to-Date by following PowerApps on Twitter

Top Community Contributors for July 2019

Top Community Contributors for July 2019

Let's thank our top community contributors

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

FirstImage

Power Platform World Tour

Coming to a city near you

thirdimage

PowerApps Community User Group Member Badge

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

FourthImage

Join PowerApps User Group!!

Connect, share, and learn with your peers year-round

FifthImage

Dynamics 365 and Power Platform April 2019 Release notes

Features releasing from April 2019 through September 2019!

Users Online
Currently online: 42 members 4,301 guests
Please welcome our newest community members: