Help! Filter Gallery with Multiple Combo Box

Copper Contributor

Hi All,

 

I have created a gallery and multiple Combo boxes which pull data from SharePoint.

 

I have created a filter, but when any Combo Box is blank, it doesn't work. Do you know how to amend the code so that the filter works when the Combo Boxes are blank or when a selection is chosen?

 

Filter('SharePoint FAQ', (TextInput1.Text in Title || TextInput1.Text in Description || TextInput1.Text in Topic.Value) && (Topic.Value in ComboBox5.SelectedItems.Value) && ('Target Audiance'.Value in ComboBox4.SelectedItems.Value) && (Category.Value in ComboBox2.SelectedItems.Value) && ('SP Version'.Value in ComboBox3.SelectedItems.Value))

4 Replies

Does anyone have any ideas?

@Alexread1765 I don't know if this will directly help you but for one of my apps I have a couple of dropdowns rather than comboboxes. The user can select from either or both and it will filter the gallery accordingly.

 

1-ddEverything.png

 

2-ddEverywhere.png

 

I try not to leave a blank selection for my dropdowns and comboboxes where possible and so in the OnVisible property for the screen I have used the following which creates the first item as "Everywhere" or "Everything" as appropriate and then creates the collection:

 

ClearCollect(colItems, {Result: "Everything"});
Collect(colItems, Distinct(SurveyEquipment, Category));
ClearCollect(colEverywhere, {Result: "Everywhere"});
Collect(colEverywhere, Distinct(SurveyOffices, Title));

 

3-onVisible.png

 

Then in the items property of the gallery I have used the following to check the different combination of possible selections and filter the gallery:

Sort( 
    If(ddCategory.Selected.Result="Everything" And ddLocation.Selected.Result = "Everywhere", 
Filter(colEquipment, Available=true),
ddCategory.Selected.Result="Everything" And ddLocation.Selected.Result <> "Everywhere",
Filter(colEquipment, Location= ddLocation.Selected.Result && Available=true),
ddCategory.Selected.Result <> "Everything" And ddLocation.Selected.Result = "Everywhere",
Filter(colEquipment, Category = ddCategory.Selected.Result && Available=true),
ddCategory.Selected.Result <> "Everything" And ddLocation.Selected.Result <> "Everywhere",
Filter(colEquipment, Category = ddCategory.Selected.Result And Location = ddLocation.Selected.Result && Available=true)),Category,Ascending)

  

4-galItems.png

 

5-itemsDropdown.png

 

Hope that gives you some ideas.

 

Rob
Los Gallardos
Intranet, SharePoint and Power Platform Manager (and classic 1967 Morris Traveller driver)

 

@Alexread1765 

Try this approach -

Filter(
        'env-List-ContactsSample',
        (
            (
                (Topic = ComboBox5.Selected.Result || IsBlank(ComboBox5.Selected.Result)) &&
                ('Target Audience' = ComboBox4.Selected.Result || IsBlank(ComboBox4.Selected.Result)) &&
                Category = ComboBox3.Selected.Result || IsBlank(ComboBox3.Selected.Result)) &&
                (
                TextInput1.Text in Title ||
                TextInput1.Text in Description ||
                TextInput1.Text in Topic.Value
                )
            )
        )
    )

@Alexread1765 Use this formula in items property of gallery control: 

 

Filter(
	'SharePoint FAQ',
	TextInput1.Text in Title || TextInput1.Text in Description || TextInput1.Text in Topic.Value,
	IsEmpty(ComboBox5.SelectedItems.Value) || IsBlank(ComboBox5.SelectedItems.Value) || Topic.Value in ComboBox5.SelectedItems.Value,
	IsEmpty(ComboBox4.SelectedItems.Value) || IsBlank(ComboBox4.SelectedItems.Value) || 'Target Audiance'.Value in ComboBox4.SelectedItems.Value,
	IsEmpty(ComboBox2.SelectedItems.Value) || IsBlank(ComboBox2.SelectedItems.Value) || Category.Value in ComboBox2.SelectedItems.Value,
	IsEmpty(ComboBox3.SelectedItems.Value) || IsBlank(ComboBox3.SelectedItems.Value) || 'SP Version'.Value in ComboBox3.SelectedItems.Value
)

 

DocumentationFilter, Search, and LookUp functions in Power Apps 


Please click Mark as Best Response & Like if my post helped you to solve your issue. This will help others to find the correct solution easily. It also closes the item. If the post was useful in other ways, please consider giving it Like.