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 / Remove selected item f...
Power Apps
Unanswered

Remove selected item from multi select based on another selection in SAME combobox?

(0) ShareShare
ReportReport
Posted on by 829

Hi Folks -

I have a multiselect ComboBox that is multiselect.  There are times when the users can select a value called "Not Applicable" and then submit.  However, I need functionality to remove the "Not Applicable" when there is another value selected. Is this possible?

 

For instance, if "Not Applicable" is selected, then "Value2" is select, I need to remove "Not Applicable" from the selection.

 

Thank you!

Categories:
I have the same question (0)
  • mdevaney Profile Picture
    29,989 Moderator on at

    @simms7400 

    In my humble opinion the best way to ensure a valid selection is made would be to prevent the user from making an invalid selection.  For example, suppose you have a collection like this

     

    ClearCollect(
     myCollection,
     {Value: "Option 1"},
     {Value: "Option 2"},
     {Value: "Option 3"},
     {Value: "Not Applicable"}
    );

     

    Now create a new ComboBox with these properties

     

    Items: myCollection
    DisplayFields: ["Value"]

     

    You can prevent the user from selecting Not Applicable when another Option is already selected and vice versa by putting this code in the OnChange property of the ComboBox.

     

     

    If(
     "Not Applicable" in ComboBox1.SelectedItems.Value,
     ClearCollect(myCollection,{Value: "Not Applicable"}),
     If(
     IsEmpty(ComboBox1.SelectedItems.Value),
     ClearCollect(
    myCollection,
    {Value: "Option 1"},
    {Value: "Option 2"},
    {Value: "Option 3"},
    {Value: "Not Applicable"}
    ), Remove(myCollection,{Value: "Not Applicable"}); ) );

     

    Give this method a try for yourself in a Test Application.  I think you'll like it!

     

    ---
    Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."

  • simms7400 Profile Picture
    829 on at

    @mdevaney  

     

    Thank you for the solution, this is working as you intended it. However, it's not quite what I need.  For instance, a user can select "Not Applicable" from the list of drop downs based on what data element he or she is creating and submit that.  However, if "Not Applicable" + 1 or mor eother values are also picked, I need to REMOVE Not Applicable from the list of selected items so it's not submitted.

     

    Unfortunately, I'm unable to use another field as a control or check to say "If this field is selected, then hide "Not Applicable" from the Combobox...I'm unable to do this.

     

    Can this be modified for my need?

  • simms7400 Profile Picture
    829 on at

    Added this to this to the first line and it seems to work!

     

    "Not Applicable" in CB_Device_Platform.SelectedItems.Alias && CountRows(CB_Device_Platform.SelectedItems.Alias)>=2

    Will test with the users today.  Thank you! I will report back.

  • v-xida-msft Profile Picture
    on at

    Hi @simms7400 ,

    I have made a test on my side, please consider take a try with the following workaround:9.JPG

    Set the Items property of the ComboBox to following:

    ["Not Applicable", "Value2", "Value3"]

    Set the OnChange property of the ComboBox to following:

    ClearCollect(TempCollection, ComboBox1.SelectedItems);
    If(
     Last(FirstN(TempCollection, 2)).Value="Value2" && Last(FirstN(TempCollection, 1)).Value="Not Applicable",
     RemoveIf(TempCollection, Value="Not Applicable")
    )

    Set the DefaultSelectedItems property of ComboBox to following:

    ForAll(TempCollection, {Value: Value})

    Please take a try with above solution, check if the issue is solved.

     

    Best regards,

  • simms7400 Profile Picture
    829 on at

    @mdevaney 

     

    I tested the code you gave me (modifying it with my name specifics of course) and its WORKS, however it's just a little bit clunky.  For instance, if user selects "Not Applicable" and then anoher value, the field will get wiped clean but I still need to click on the field, X the "Not Appliable" and then select other value.  My hope was after "Not Applicable" was removed after it met the condition in your code, I wouldn't need to do anything else but select the new values.

     

    Thoughts?

     

    @v-xida-msft 

     

    Hmmm, this loks promising, but my Items property for this box is already set to:

    If( DataCardValue133.Selected.Value="Device",
    	Filter(Sort(DevicePlatformList,Alias, Ascending),Alias<>"Not Applicable"),
    	Sort(DevicePlatformList,Alias, Ascending)
    )

    And since is a multi-select field, my defaultselecteditems property is set to the following:

    Filter(DevicePlatformList, Alias in Split(ThisItem.Device_Platform, ",")).Alias

    How would I leverage your soluction with my above things already in place? Thanks!

  • mdevaney Profile Picture
    29,989 Moderator on at

    @simms7400 

    PowerApps doesn't let us change the combobox options until a change is completed (your desire) nor does it allow us to manipulate the selection of the combobox once made.  I'm afraid all you can do here is give the user some visual cues (highlight the combo border red) or show an error when they select both at once.  You can also write some form validation code to prevent submission.  Of course, these are just general tips.  Hopefully I have answered you question in an easy to understand way.  Unfortunately, I do not see a really good workaround here.

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
Kalathiya Profile Picture

Kalathiya 419

#2
WarrenBelz Profile Picture

WarrenBelz 397 Most Valuable Professional

#3
MS.Ragavendar Profile Picture

MS.Ragavendar 345 Super User 2025 Season 2

Last 30 days Overall leaderboard