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

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Limit choices in dropd...
Power Apps
Answered

Limit choices in dropdown to limit how many times an item can be selected

(0) ShareShare
ReportReport
Posted on by 4

I have a newbie question for an app we are trying to build.  We have 10 classes with different amounts of seats in each.  To limit the selections staff make, we are trying to use the OnChange action on the dropdown to send a warning if more than a specific number of classes are in the SharePoint list already.

If(CountIf('Engage Classes', 'Class'.Value = "Choice 1") > 3, "Class at max")

 

I’m not sure if I am using the correct action for this since it does not seem to do anything.  Am I using the correct action to check this before submission?

Categories:
I have the same question (0)
  • Verified answer
    Ami K Profile Picture
    15,689 Super User 2024 Season 1 on at

    @shutterspeed100 - I think the below is what you're trying to do:

     

    If(
     CountRows(
     Filter(
     'Engage Classes',
     Class.Value = "Choice 1"
     )
     ) > 3,
     Notify(
     "Class at max",
     NotificationType.Warning
     )
    )

     

    If the Items property of your Dropdown control has been populated with the Class choice field (e.g. Choices(['Engage Classes'].Class), then you can use a slight modification by referencing the Dropdown control itself (Self.Selected.Value)

     

    If(
     CountRows(
     Filter(
     'Engage Classes',
     Class.Value = Self.Selected.Value
     )
     ) > 3,
     Notify(
     "Class at max",
     NotificationType.Warning
     )
    )

     

    Note that the CountRows function is not delegable. However, because you are already filtering your list based on a specific Choice from your Choice field, and if you can guarantee that there will not be more than 2000 rows with that criteria, you will be safe to ignore this.

     

    If you want to hide that warning, you can use the With function. This will output the same result as the above, but with the warning hidden:

     

    With(
     {
     _prefiltered_data: Filter(
     'Engage Classes',
     Class.Value = Self.Selected.Value
     )
     },
     If(
     CountRows(_prefiltered_data) > 3,
     Notify(
     "Class at max",
     NotificationType.Warning
     )
     )
    )
    
  • Verified answer
    v-qiaqi@microsoft.com Profile Picture
    Microsoft Employee on at

    HI @shutterspeed100,

    To check it before submission, I think you could keep your If statement, but change it to a Label Text property instead of the OnChange property.

     

    Add a Label and set its Text property as:

    If(CountIf('Engage Classes', 'Class'.Value = "Choice 1") > 3, "Class at max")

    Then set the Visible property of the Label as:

    CountIf('Engage Classes', 'Class'.Value = "Choice 1") > 3

    Set the DisplayMode property of your submit button as:

    If(CountIf('Engage Classes', 'Class'.Value = "Choice 1") > 3, DisplayMode.Disabled,DisplayMode.Edit)​

     

    The above will enforce users to select correct calss before submission.

  • shutterspeed100 Profile Picture
    4 on at

    Thanks, let me give these a try.  Both options sound like they would work.

  • shutterspeed100 Profile Picture
    4 on at

    Thanks for pointing me in the right directions.  I was able to do what I was trying to do with the code below.  Any suggestions on how cleaning it up?

     

    If(
     Self.Selected.Value = "Choice 2" && CountRows(
     Filter(
     'Engage Classes',
     Class.Value = Self.Selected.Value
     )
     ) >= 2,
     Notify(
     "Class 2 at max",
     NotificationType.Warning
     )
    ) Or If(
     Self.Selected.Value = "Choice 1" && CountRows(
     Filter(
     'Engage Classes',
     Class.Value = Self.Selected.Value
     )
     ) >= 1,
     Notify(
     "Class 1 at max",
     NotificationType.Warning
     )
    ) Or If(
     Self.Selected.Value = "Choice 3" && CountRows(
     Filter(
     'Engage Classes',
     Class.Value = Self.Selected.Value
     )
     ) >= 3,
     Notify(
     "Class 3 at max",
     NotificationType.Warning
     )
    )

     

     

  • Ami K Profile Picture
    15,689 Super User 2024 Season 1 on at

    @shutterspeed100 - I would use:

     

    With(
     {
     _metadata: Table(
     {
     ChoiceText: "Choice 1",
     Maximum: 1
     },
     {
     ChoiceText: "Choice 2",
     Maximum: 2
     },
     {
     ChoiceText: "Choice 3",
     Maximum: 3
     }
     )
     },
     If(
     CountRows(
     Filter(
     'Engage Classes',
     Class.Value = Self.Selected.Value
     )
     ) >= LookUp(
     _metadata,
     ChoiceText = Self.Selected.Value,
     Maximum
     ),
     Notify(
     Self.Selected.Value & " at max",
     NotificationType.Warning
     )
     )
    )

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 392 Most Valuable Professional

#2
11manish Profile Picture

11manish 181 Super User 2026 Season 2

#3
MS.Ragavendar Profile Picture

MS.Ragavendar 112 Super User 2026 Season 2

Last 30 days Overall leaderboard