Forum Discussion

Alexread1765's avatar
Alexread1765
Copper Contributor
Feb 15, 2022

Help! Filter Gallery with Multiple Combo Box

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))

  • 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.

  • RobElliott's avatar
    RobElliott
    Silver Contributor

    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.

     

     

     

    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));

     

     

    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)

      

     

     

    Hope that gives you some ideas.

     

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

     

  • SpoTech's avatar
    SpoTech
    Copper Contributor

    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
                    )
                )
            )
        )

Resources