cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Helper I
Helper I

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
Highlighted
Frequent Visitor

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

Highlighted
Helper I
Helper I

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
Highlighted
Frequent Visitor

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)

 

ExampleExample

Highlighted
Frequent Visitor

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)

 

ExampleExample

Highlighted
Helper I
Helper I

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.

Highlighted
Frequent Visitor

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

Helper I
Helper I

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
Helper I
Helper I

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 .

Highlighted
Helper I
Helper I

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
secondImage

New Return to Workplace

Reopen responsibly, monitor intelligently, and protect continuously with solutions for a safer work environment.

Experience what’s next for Power Apps

Join us for an in-depth look at the new Power Apps features and capabilities at the free Microsoft Business Applications Launch Event.

Check this Out

Helpful information

Featuring samples like Return to the Workplace and Emergency Response Applications

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Top Solution Authors
Top Kudoed Authors
Users online (8,582)