cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Frequent Visitor

Combo Box filtering gallery

Hello,

 

I'm having an issue with filtering a gallery with a combo box. I've unsuccesfully tried to resolve this issue all morning. Here's what's happening:

 

I have a combo box filtering a gallery. I have an if statement for the gallery Items that states if the combo box is empty, show the entire table. If something is selected then filter the gallery accordingly. Something like this:

 

Items=If(IsEmpty(ComboBox.SelectedItems.Column) ,table , Filter(table,Column in ComboBox.SelectedItems.Column))

 

The issue is when I navigate to the screen, the gallery shows up empty, whereas it should be showing all items since there is no selected item in the combobox. As soon as I select an item from the combobox, and the remove it from the combobox, the gallery shows all records (as it should). 

 

I've tried setting the combobox DefaultSelectedItems = [ ], DefaultSelectedItems = Blank(), Default = Blank(), but all that didn't work. 

 

Any ideas?

 

Thanks in advance!

 

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Community Support
Community Support

Re: Combo Box filtering gallery

Hi @marksmyth ,

Based on the issue that you mentioned, I have made a test on my side based on your formula, the issue is confirmed on my side.

I think this issue may be related to the IsEmpty() function within your formula. The IsEmpty(ComboBox.SelectedItems) formula would return false continuously, regardless of whether the Combo Box is empty. So you could not use IsEmpty() function to detect if the Combo Box is empty.

As an alternative solution, I have made a test on my side, please take a try with the following workaround:10.JPG

Set the Items property of the Combo Box to following:

If(
IsBlank(ComboBox2.Selected.Value),
'20190211_case5',
Filter('20190211_case5', 'Account Coordinator'.Value in ComboBox2.SelectedItems.Value)
)

On your side, you should type:

If(
IsBlank(ComboBox.Selected.Column), /* <-- Modify formula here */
table,
Filter(table,Column in ComboBox.SelectedItems.Column)
)

Or

If(
   IsBlank(ComboBox.Selected), /* <-- Modify formula here */
   table, 
   Filter(table,Column in ComboBox.SelectedItems.Column)
)

Or

If(
   IsBlank(ComboBox.Selected.Value), /* <-- Modify formula here */
   table, 
   Filter(table,Column in ComboBox.SelectedItems.Column)
)

 

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

8 REPLIES 8
Highlighted
Power Apps
Power Apps

Re: Combo Box filtering gallery

If(IsEmpty(ComboBox.SelectedItems.Column) ,table , Filter(table,Column in ComboBox.SelectedItems.Column))

Can you try eliminating the drill down into .Column? Since ComboBox.SelectedItems is already a table, you would not need to drill down to check if it is empty or not.

 

You also need the DefaultSelectedItems to have the exact same column structure as the Items of the ComboBox. Can you check that they indeed line up?

Highlighted
Frequent Visitor

Re: Combo Box filtering gallery

I eleminated the drill down - all good.

 

I tried making DefaultSelectedItems the exact same as the Items. However when I do so what happens is that when navigating to the screen all items in the combo box get selected, which is what I need, but then I need to unselect them one at a time to remove them, hence this is why I used the If(IsEmpty(... formula for the gallery.  

 

When I leave the DefaultSelectedItems blank, I navigate to the screen and the combo box is empty, which is what I want, however it seems the gallery is still filtering for the items in the combo box and finds nothing, therefore the gallery is empty. 

Highlighted
Community Support
Community Support

Re: Combo Box filtering gallery

Hi @marksmyth ,

Based on the issue that you mentioned, I have made a test on my side based on your formula, the issue is confirmed on my side.

I think this issue may be related to the IsEmpty() function within your formula. The IsEmpty(ComboBox.SelectedItems) formula would return false continuously, regardless of whether the Combo Box is empty. So you could not use IsEmpty() function to detect if the Combo Box is empty.

As an alternative solution, I have made a test on my side, please take a try with the following workaround:10.JPG

Set the Items property of the Combo Box to following:

If(
IsBlank(ComboBox2.Selected.Value),
'20190211_case5',
Filter('20190211_case5', 'Account Coordinator'.Value in ComboBox2.SelectedItems.Value)
)

On your side, you should type:

If(
IsBlank(ComboBox.Selected.Column), /* <-- Modify formula here */
table,
Filter(table,Column in ComboBox.SelectedItems.Column)
)

Or

If(
   IsBlank(ComboBox.Selected), /* <-- Modify formula here */
   table, 
   Filter(table,Column in ComboBox.SelectedItems.Column)
)

Or

If(
   IsBlank(ComboBox.Selected.Value), /* <-- Modify formula here */
   table, 
   Filter(table,Column in ComboBox.SelectedItems.Column)
)

 

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

Highlighted
Frequent Visitor

Re: Combo Box filtering gallery

May be this is a stupid qustion. 
I am not a programmer. I see videos and answers in this community to make apps I need.


Question:
Is there a way for

Filter(table,Column in ComboBox.SelectedItems.Column)

to filter for exact match?
I have a lot of similar values. It picks up all of them.

Attched a sample list of items in the column I am trying to filter. The start of all is similar.

Highlighted
Frequent Visitor

Re: Combo Box filtering gallery

Im getting circular reference error when i place the code on within my combobox.

Highlighted
Power Apps
Power Apps

Re: Combo Box filtering gallery

@nizam1011,

To get exact matches, you can use the exactin operator. It works exactly as 'in' does except that it looks for exact matches as its name entails.

 

Something like this should work:

Filter(table,Column exactin ComboBox.SelectedItems.Column)

 

Highlighted
Power Apps
Power Apps

Re: Combo Box filtering gallery

@Kenneth,

Can you share more about what you're copy pasting and the exact error you're getting? If this is a very different context than the OPs, it is helpful to start a new thread so your post is distinguished.

Highlighted
Regular Visitor

Re: Combo Box filtering gallery

You can use this condition:

If(
        CountRows(ComboBox1.SelectedItems)<1;
        TABLE;
        Filter(
            TABLE;
            COLUMN.Value = ComboBox1.Selected.Value //(or column)
        )
    )

 

This work for me since the screen is visible. 

Helpful resources

Announcements
secondImage

New Return to Workplace

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

August 2020 CYST Challenge

Check out the winners of the recent 'Can You Solve These?' community challenge!

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 (3,118)