cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Julass
Regular Visitor

Filter multi selection choices column with selectmultiple combobox

Hi,

 

I try to create a tool to filter gallery with choices column.

 

Here is my dataverse table:

 

table.png

Here are my settings:
table name: 'Tasks Infos'
combobox name: subtasksFilter

subtasksFilter items: Choices('Tasks Infos'.Subtasks)

gallery items: 

Filter('Tasks Infos'; Concat(subtasksFilter.SelectedItems; Value & ",") in Concat(Subtasks; Value & ","))

 

I used this solution but it doesn't work perfectly. Items are hidden when filter is not enabled and doesn't work properly when combobox selection has wrong order. Here is what it looks like:

filter1.PNG

filter2.PNG

I would assume that by selecting 1, 3 gallery displays:

 

filter3.png

 

What is wrong with this formula? I tried before with Sharepoint list with choice that allow multiple selections but it works the same and also I read that sharepoint list has more limitation and dataverse is the database that I should use.

1 ACCEPTED SOLUTION

Accepted Solutions

I found a solution in this video. It works but it is not ideal. It forces to use single line text as a source and not choices. Adding additional combobox makes the function looks like spaghetti. 

I put here a code for others:
App OnStart:

ClearCollect(
    colItems,
    TestList2
);
ClearCollect(
    colOptions,
    RenameColumns(
        AddColumns(
            ["dog", "chicken", "pet", "boswell", "young"],
            "IsChoosen",
            true
        ),
        "Value",
        "OptionName"
    )
);


ComboBox1_2 Items:

colOptions


Reset icon OnSelect:

ClearCollect(colYourItems, colItems);
Reset(ComboBox1_2);


Filter button OnSelect:

// diselect all options
UpdateIf(colOptions, true, {IsChoosen: false});

// change IsChoosen to true for selected items from combobox
ForAll(
    ComboBox1_2.SelectedItems As _item,
    If(_item in colOptions, Patch(colOptions, _item, {IsChoosen: true}))
);

// create empty collection that match exact
Clear(colItemsToShowExact);

// add items to exact collection based on IsChoosen
ForAll(
    Filter(
        colOptions,
        IsChoosen
    ) As FilterChoices,
    Collect(
        colItemsToShowExact,
        Filter(
            colItems,
            FilterChoices.OptionName in ItemType
        )
    )
);

// remove duplicated items from exact collection
ClearCollect(
    colYourItems,
    Filter(
        GroupBy(
            colItemsToShowExact,
            "ItemName",
            "ItemType",
            "Color",
            "DATA"
        ),
        CountRows(DATA) = CountRows(
            Filter(
                colOptions,
                IsChoosen
            )
        )
    )
);


Gallery Items:

colYourItems

 

Julass_5-1626417656642.png

 

 

View solution in original post

4 REPLIES 4
Nogueira1306
Community Champion
Community Champion

I think the problem is in your concat 

 

Concat(subtasksFilter.SelectedItems; Value & ",")

This will make "new1, new 2, new 3" 

A filter does not work like that

Filter(Source; task = Dropdown.Selecteditem)


Not sure if thats why.. But I never saw a filter like yours... You dont have the "logic test"

This formula gives an error: wrong comparison type.

Filter('Tasks Infos'; Subtasks = subtasksFilter.SelectedItems)

 

Nogueira1306
Community Champion
Community Champion

After the selected items you need to put .Value

And I am not sure if it will work for many items, as I said before

I found a solution in this video. It works but it is not ideal. It forces to use single line text as a source and not choices. Adding additional combobox makes the function looks like spaghetti. 

I put here a code for others:
App OnStart:

ClearCollect(
    colItems,
    TestList2
);
ClearCollect(
    colOptions,
    RenameColumns(
        AddColumns(
            ["dog", "chicken", "pet", "boswell", "young"],
            "IsChoosen",
            true
        ),
        "Value",
        "OptionName"
    )
);


ComboBox1_2 Items:

colOptions


Reset icon OnSelect:

ClearCollect(colYourItems, colItems);
Reset(ComboBox1_2);


Filter button OnSelect:

// diselect all options
UpdateIf(colOptions, true, {IsChoosen: false});

// change IsChoosen to true for selected items from combobox
ForAll(
    ComboBox1_2.SelectedItems As _item,
    If(_item in colOptions, Patch(colOptions, _item, {IsChoosen: true}))
);

// create empty collection that match exact
Clear(colItemsToShowExact);

// add items to exact collection based on IsChoosen
ForAll(
    Filter(
        colOptions,
        IsChoosen
    ) As FilterChoices,
    Collect(
        colItemsToShowExact,
        Filter(
            colItems,
            FilterChoices.OptionName in ItemType
        )
    )
);

// remove duplicated items from exact collection
ClearCollect(
    colYourItems,
    Filter(
        GroupBy(
            colItemsToShowExact,
            "ItemName",
            "ItemType",
            "Color",
            "DATA"
        ),
        CountRows(DATA) = CountRows(
            Filter(
                colOptions,
                IsChoosen
            )
        )
    )
);


Gallery Items:

colYourItems

 

Julass_5-1626417656642.png

 

 

View solution in original post

Helpful resources

Announcements
PA_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

secondImage

Power Apps Community Call

Please join us on Wednesday, October 20th, at 8a PDT. Come and learn from our amazing speakers!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

Welcome Super Users.jpg

Super User Season 2

Congratulations, the new Super User Season 2 for 2021 has started!

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

Top Solution Authors
Users online (2,543)