cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
New Member

Combo box selected items limit

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!

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Super User
Super User

Re: Combo box selected items limit

Hi @TatiDmngs,

 

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


@iAm_ManCat

Please 'Mark as Solution' if someone's post answered your question and always 'Thumbs Up' the posts you like or that helped you!


Thanks!
You and everyone else in the community make it the awesome and welcoming place it is, keep your questions coming and make sure to 'like' anything that makes you 'Appy
Sancho Harker, MVP


View solution in original post

7 REPLIES 7
Highlighted
Community Support
Community Support

Re: Combo box selected items limit

Hi @TatiDmngs,

 

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

Community Support Team _ Mona Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Highlighted
Super User
Super User

Re: Combo box selected items limit

Hi @TatiDmngs,

 

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


@iAm_ManCat

Please 'Mark as Solution' if someone's post answered your question and always 'Thumbs Up' the posts you like or that helped you!


Thanks!
You and everyone else in the community make it the awesome and welcoming place it is, keep your questions coming and make sure to 'like' anything that makes you 'Appy
Sancho Harker, MVP


View solution in original post

Highlighted
Community Champion
Community Champion

Re: Combo box selected items limit

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

 

@TopShelf-MSFT

Highlighted
Super User
Super User

Re: Combo box selected items limit

You're welcome, always glad to help 🙂


@iAm_ManCat

Please 'Mark as Solution' if someone's post answered your question and always 'Thumbs Up' the posts you like or that helped you!


Thanks!
You and everyone else in the community make it the awesome and welcoming place it is, keep your questions coming and make sure to 'like' anything that makes you 'Appy
Sancho Harker, MVP


Highlighted
Anonymous
Not applicable

Re: Combo box selected items limit

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.

Highlighted
Anonymous
Not applicable

Re: Combo box selected items limit

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.

Highlighted
Anonymous
Not applicable

Re: Combo box selected items limit

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

It would make our life a bit easier Smiley Wink

Helpful resources

Announcements
secondImage

Demo-Extravaganza 2020

Check out these cool Power Apps & vote on your favorite!

secondImage

Community Highlights

Check out whats happening in Power Apps

secondImage

Community User Group Member Badges

FIll out a quick form to claim your community user group member badge today!

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Top Solution Authors
Top Kudoed Authors
Users online (8,587)