cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Anonymous
Not applicable

Combo box to search / filter a Gallery

I have a combo box, SelectTags, driven by excel table TagList (["Sales,"Stock","Orders"...]

I have a gallery ReportCatalogue with a field Tags which looks like "Sales, Stock" for the first item and "Sales, Orders, Stock" for the next and so on

 

How to I filter the gallery by the combo box

For example Search(ReportCatalogue, SelectTags.SearchText , "Tags" ) works when I type in the combo box but not when I select from the drop down

But then Text(SelectTags.SelectedItems) doesn't work for the drop down.... nothing does

 

how can I filter the gallery for the multiple combo box selections please?

3 REPLIES 3
Microsoft Employee

Re: Combo box to search / filter a Gallery

This can definetely be done. Do you intend to filter your table by more than one value at a time? For example, do you want to select more than one tags in your ComboBox and then filter the table by all the tags? I assume that is not the case since you're binding to Excel.

Before applying the formula below, make sure your ComboBox control is in single select mode (ComboBox1.SelectMultiple = false)

ComboBox1.Items=TagList.Tags

Gallery1.Items=Filter(TagList, Tags=ComboBox1.Selected.Tags)

 

If your intent is to select multiple tags in the ComboBox control then:

ComboBox1.SelectMultiple=true

ComboBox1.Items=TagList.Tags

Gallery1.Items=Filter(TagList, Tags in ComboBox1.SelectedItems.Tags)

Anonymous
Not applicable

Re: Combo box to search / filter a Gallery

Sorry its my understanding of the solution - the error is "Invalid Name", could you explain further the solution?

 

I want is to be able to select multiple options from a combo box

Then I want to search 1 column in my data set and bring back all the items in my data set which match each of the seelctions from the combo box

 

TagList = ["Sales", "Stock", "Availability", "Orders", ...]

(single column excel table)

 

ReportCatalogue:

(multiple columns data excel table)

Item     Tag (string)

row1    Sales, Stock

row2    Stock

row3    Sales, Availabiltiy, Orders

 

ComboBox1.Items = TagList

 

Lets say I select Sales from the combo box - I would expect the gallery to filter items 1 and 3

 

If I chose stock - I would expect the gallery to filter for items 1 and 2

 

If I chose stock and sales (in that order) - I would expect the gallery to filter item 1

 

 

 

Please any help would be amazing because I am stumped and I know it can do this - it's just I can't!

 

 

Microsoft Employee

Re: Combo box to search / filter a Gallery

I corrected a small error in my previous post (added commas).

I'm not sure why you're getting the error when trying to assign Tags. You can try either to assign TagList to your ComboBox and then choose proper DisplayFields and SearchFields, or you should be able to add TagList.Tags dirrectly (are there any subvalues for the Tags, such as TagList.Tags.Value)?

In your example, the filtering could only be done with string comparisson which does not seem good.

Consider the example, when you have 2 tags: "Sales" and "Top Sales". Since both have a common word while being separate tags, it will not be straightforward to use a simple string comparisson (even using a RegEx would not be easy).

The intended behaviour can be obtained with a data source that is aware of multiple items. For example, if the dataset is a SharePoint list, Tags is a predifined list and the Tags is a column of type "Multi select Choice" in that list, then you could use "in" operations in your Filter formula to achieve the proper result - something like:

Gallery1.Items=Filter(Table1, If("MyTag1" in TagList.Tags, "MyTag1" in ComboBox1.SelectedItems.Tags) || If("MyTag2" in TagList.Tags, "MyTag2" in ComboBox1.SelectedItems.Tags))

The idea is that we say if the first tag is in the table row, then filter if that tag (ifrst tag) is also in the list of combobox sleected items, then do the same for the second tag and so on.