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 / Error Message When sel...
Power Apps
Answered

Error Message When selecting duplicates from multiple dropdowns

(1) ShareShare
ReportReport
Posted on by 10
So, I have 7 dropdown boxes all with ["1","2","3","0"] in the items fx bar. What I'm trying to accomplish is set an error message that prevents the user from submitting the power apps form if the selections 1, 2, 3 are selected more than once. 0 is fine to be selected more than once. Is there a way to do this? I've looked all over and can't seem to find anything.
I have the same question (0)
  • WarrenBelz Profile Picture
    155,293 Most Valuable Professional on at
    A Combo Box will not allow the user to select the same value twice - selecting it again deletes it. I can give you are rather complex formula OnChange, but you should not need it.
    If(
       CountRows(
          GroupBy(
             Self.SelectedItems,
             Value,
             Data
          )
       ) < CountRows(Self.SelectedItems),
       Reset(Self);
       Notify(
          "Cannot duplicate choices",
          NotificationType.Error,
          5000
       )
    )
     
    Please click Does this answer your question if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it a Like.
    MVP (Business Applications)     Visit my blog Practical Power Apps    Buy me a coffee
  • Suggested answer
    Michael E. Gernaey Profile Picture
    53,978 Moderator on at
    HI,
     
    Only because I read it a little differently than Warren will I respond, otherwise :-) I'd leave it for him same as we usually do for each other.
     
    If you have 7 dropdowns on a Form.
     
    This is what I would do.
     
    1. In each of the Dropdowns OnChange I would add this, but where it says Dropdown = 1, you simply put in the Number 1-7 as you have 7 so that the Collection can know which specific Selection is adding the Value to our SelectionCounts collection
     
    So you end up with a Table that has records like
     
    {
       Dropdown: 1,
       Value: TheTextValue of the chosen value in the Dropdown. IF the dropdown already has a value, it does an update, if not it adds it. So you end up with 7 Rows in this Collection once they have selected values in all 7
    }
    If(IsEmpty(SelectionCounts) Or IsBlank(LookUp(SelectionCounts, Dropdown = 1)),
        Collect(SelectionCounts, { Dropdown: 1, Value: Text(Self.Selected.Value) });
    ,
        UpdateIf(SelectionCounts,  Dropdown = 1, {Value: Text(Self.Selected.Value) });
    );
    
     
    Now in the DisplayMode of the Save Button I would put
    If(CountRows(Filter(SelectionCounts, Value = "1")) > 1 
        Or CountRows(Filter(SelectionCounts, Value = "2")) > 1
        Or CountRows(Filter(SelectionCounts, Value = "3")) > 1,
        DisplayMode.Disabled,
        DisplayMode.Edit
    )
    This checks to see if the Value 1 or 2 or 3, has more than 1 Row in the collection and if so it sets the DisplayMode to Disabled.
     
    Of course you should always have IsBlank checks to make sure that they actually picked 7 values, in addition to the DisplayMode code I added.
    I selected 1 twice and it disabled the button.
     
     
    or with different ones
     
     
    Or if you want to display a Message to them, then you can put the code thats in the button OnSelect
    If(CountRows(Filter(SelectionCounts, Value = "1")) > 1
    Or CountRows(Filter(SelectionCounts, Value = "2")) > 1
    Or CountRows(Filter(SelectionCounts, Value = "3")) > 1,
    DisplayMode.Disabled,
    DisplayMode.Edit
    )


    into the OnChange of every dropdown, after the other OnChange code runs... or just disable the button as I have here.


    Anyway, I could have read it wrong as i mentioned so apologies if I did, but I was going for 7 separate dropdowns on a form
     
     
     

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the April Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
Vish WR Profile Picture

Vish WR 1,027

#2
Valantis Profile Picture

Valantis 644

#3
11manish Profile Picture

11manish 626

Last 30 days Overall leaderboard