web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Combo box selected ite...
Power Apps
Unanswered

Combo box selected items limit

(0) ShareShare
ReportReport
Posted on by

Hello,

 

I've been struggling quite a lot to find a solution for this and I'm not sure wether it's possible. I have a combo box with N options and I'd like to set the maximum amount of how much choices the user can make in 10. I've tried to use this on the Disabled property: "If(CountRows(ComboBox3.SelectedItems) > 10,DisplayMode.Disabled,DisplayMode.Edit)" but this wouldn't allow the users to change their previous selection so it doesn't really fit my needs.

 

I appreciate any help, thank you!

Categories:
I have the same question (0)
  • v-monli-msft Profile Picture
    on at

    Hi @Anonymous,

     

    Sorry but I cannot think of other ways to achieve your requirement. There is no such property that you could set for combobox control according to https://docs.microsoft.com/en-us/powerapps/maker/canvas-apps/controls/control-combo-box. You might want to add an idea in the PowerApps Ideas forum, to ask for adding a property to limit the max selectable numbers of options in combobox control.

    https://powerusers.microsoft.com/t5/PowerApps-Ideas/idb-p/PowerAppsIdeas

     

    Regards,

    Mona Li

  • Verified answer
    iAm_ManCat Profile Picture
    18,228 Most Valuable Professional on at

    Hi @Anonymous,

     

    You can't hardcode it currently as there's no option for limiting, but you can lead the user to do it:

    I would have the following triggered via the OnChange of your combo box:
    If(
       CountRows(ComboBox3.SelectedItems) > 10,
       
    notify("Please choose no more than 10 items", notificationtype.error)
    )

     

    ..then I would have the Displaymode for any Submit  button have your
    If(CountRows(ComboBox3.SelectedItems) > 10,DisplayMode.Disabled,DisplayMode.Edit)
    That way they can't submit until they've fixed their error.

     

    Let me know if that would be an acceptable workaround!

     

    Cheers,

    @iAm_ManCat

  • Community Power Platform Member Profile Picture
    on at

    Thanks for your help with this post and all the knowledge you've provided the PowerApps Community @iAm_ManCat

     

    @Anonymous

  • iAm_ManCat Profile Picture
    18,228 Most Valuable Professional on at

    You're welcome, always glad to help 🙂

  • Community Power Platform Member Profile Picture
    on at

    I know this is an old post, but in case anyone runs into a similar issue, I thought of another possible solution. Set the OnChange property of the combobox to:

    If(CountRows(Combobox.SelectedItems)>10, Reset(Combobox)

    This will cause all 10 items to clear when the user attempts to select an 11th item. Not ideal, but it will enforce the desired limit. I tried creating a Gallery and setting its 'items' property to (FirstN,Combobox.SelectedItems,10) - Then setting the Combobox's DefaultSelectedItems to Gallery.AllItems. If it worked, that would result in perfect behavior -the Combobox would reset to the first 10 values when the user tried to select an 11th, but to the user it would simply appear they couldn't select an 11th option. Unfortunately, that creates a circular reference, which isn't allowed.

  • Community Power Platform Member Profile Picture
    on at

    Ok - totally solved!

     

    Set OnChange property of Dropdown to:

    If(CountRows(Selections)=3,UpdateContext({Selections: Blank()}));If(CountRows(Dropdown.SelectedItems)>10,Reset(Dropdown));UpdateContext({Selections: Dropdown.SelectedItems.Value})

     

    Set DefaultSelectedItems property of Dropdown to:

    If(Not(IsEmpty(Selections)),FirstN(Selections,10)))

     

    The effect is that attempting to select an 11th item makes the drop-down list close, and the 11th item is not added. The first 10 selections are still there. I'd suggest either using a Concat() to string together all of the selections and displaying with a label, or triggering an error message - so your user realizes they can only select 10 items.

  • Community Power Platform Member Profile Picture
    on at

    I've added this option as a new idea, as I think it should be added to the settings of a Combo box:

    https://powerusers.microsoft.com/t5/PowerApps-Ideas/Add-a-maximum-selectable-items-option-to-Combo-box/idi-p/317677

    It would make our life a bit easier Smiley Wink

  • Murderbot Profile Picture
    132 on at

    This worked great for me, just one question: why is selections set to 3?

  • Community Power Platform Member Profile Picture
    on at

    Hello,

     

    May be this will help to restrict number of selections in a ComboBox.

    Step 1: In Screen OnVisible property,

    OnVisible

    ClearCollect(DropdownData, {.......});

    If(IsEmpty(Items), ClearCollect(Items, First(DropdownData)));

     

    Step 2: Insert a ComboBox. Assign it's properties as follows,

    ItemsDropdownData

     

    OnChangeClearCollect(Items, ComboBox.SelectedItems);
    If(CountRows(ComboBox.SelectedItems)>10,Reset(ComboBox));

     

    DefaultSelectedItemsFirstN(Items,10);

     

    In this approach, It won't allows the 11th Selection.🙂

  • CharlesPP Profile Picture
    187 on at

    I've just come across this topic, so I'll take the liberty of giving you my solution, which is close to those proposed previously, but which I find simpler and easier to read.

    In the "OnChange" property : 

     

    With(
     {
     _nbMaxItems: 15
     },
     If(CountRows(Self.SelectedItems)>_nbMaxItems,
     Notify($"It is only possible to filter on a maximum of {_nbMaxItems} items simultaneously.", NotificationType.Error);
     UpdateContext({locComboSelected: FirstN(Self.SelectedItems, _nbMaxItems)});
     Reset(Self);
     );
    )

     

    In the "DefaultSelectedItems " property : 

     

    locComboSelected

     

     

    Have a nice day !
    Charles

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 796 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 327 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard