cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Poweruser0499
Frequent Visitor

Can I limit selections in powerapps ?

Hi power-platform experts, 

 

I'm building an application to raise demands in an organization, suppose there are 10 demands based on skill , level , availability, so If he wants a single demand he should be only able to select 2 demands of his choice out of 10 not more than that , if he wants 2 demands out of all 10 he should be able to select only 3 based on his choice. Is there a way to restrict the number of selections a person can make in gallery ?

 

Pls help me

Thankyou 

1 ACCEPTED SOLUTION

Accepted Solutions
BCLS776
Super User
Super User

Try putting this code in the DisplayMode property of the Button 9:

If(
    LookUp(ResourceCollector, Column3 = ThisItem.Column6, true) // condition to see if this item exists in the collection already
    || // Or
    CountRows(ResourceCollection) > 2, // condition to see if more than two rows are in the collection already
    Displaymode.Disabled, // If true, disable the button
    Displaymode.Edit // Otherwise, leave it enabled
)

    

This code will disable that Button9 if that record has already been selected, or if more than 2 records already exist in the collection. Does that get you closer to what you wanted?

 

_________________________________________________________________________________________
Help the community help more users by choosing to "Accept as Solution" if this post met your needs. If you liked the post and want to show some appreciation, please give it a Thumbs Up.

View solution in original post

4 REPLIES 4
BCLS776
Super User
Super User

It's a bit tough to tell from the screenshot you provided, but it is possible to control the DisplayMode of controls based on conditional logic. Keep it in Edit mode when the person has made less than 2 selections, and put the control in Disabled mode when the selections are 2 or greater.

Depending on your app logic, it may be as simple as doing a CountRows on your gallery's AllItems property to determine how many rows exist in that control and if it is more or less than 2

Hope that helps,

Bryan

_________________________________________________________________________________________
Help the community help more users by choosing to "Accept as Solution" if this post met your needs. If you liked the post and want to show some appreciation, please give it a Thumbs Up.
Poweruser0499
Frequent Visitor

Hi Bryan,

thanks for the help actually I'm new to power-apps , see I'm using a collection to store the selections made so I selected 2 profiles - ref - On select SS

 

So now when I click on view selected resources it will take me to another screen where it is connected with my collection list it shows me my selections , ref - View Selected & Results

 

Now there I can add as many resources as I want but as you said we can limit the selections so you mean we can set the display mode & add some conditions there, are you talking about the displaymode of the button ? I've also attached the formula what I'm using for Onselect & Displaymode , sorry for asking too many things pls guide me if possible ref - Onselect Button function & display mode,

 

I want the user to select random values so I'm not sure if count rows will work or not

 

Thankyou 

BCLS776
Super User
Super User

Try putting this code in the DisplayMode property of the Button 9:

If(
    LookUp(ResourceCollector, Column3 = ThisItem.Column6, true) // condition to see if this item exists in the collection already
    || // Or
    CountRows(ResourceCollection) > 2, // condition to see if more than two rows are in the collection already
    Displaymode.Disabled, // If true, disable the button
    Displaymode.Edit // Otherwise, leave it enabled
)

    

This code will disable that Button9 if that record has already been selected, or if more than 2 records already exist in the collection. Does that get you closer to what you wanted?

 

_________________________________________________________________________________________
Help the community help more users by choosing to "Accept as Solution" if this post met your needs. If you liked the post and want to show some appreciation, please give it a Thumbs Up.
Poweruser0499
Frequent Visitor

Thanks Bryan it worked for me

Helpful resources

Announcements
Ignite 2022

WHAT’S NEXT AT MICROSOFT IGNITE 2022

Explore the latest innovations, learn from product experts and partners, level up your skillset, and create connections from around the world.

Power Apps Africa Challenge 2022

Power Apps Africa Challenge

Your chance to join an engaging competition of Power Platform enthusiasts.

Super User 2 - 2022 Congratulations

Welcome Super Users

The Super User program for 2022 - Season 2 has kicked off!

September Events 2022

Check out all of these events

Attend in person or online, there are incredible conferences and events happening all throughout the month of September.

Users online (2,781)