cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Helper V
Helper V

How can I deselect the most recently selected item in a list box?

Is it possible to automatically deselect the most recently selected item in a List Box based on a formula? For example, I want to deselect an item if it already exists in a collection.

1 ACCEPTED SOLUTION

Accepted Solutions
Community Support
Community Support

Hi@pwrappr01,

Based on the issue that you mentioned, do you want to make the most recently selected item deselect in the Listbox if it already exists in a collection?

Could you please share more about your Listbox, is it multiple selections allowed or not?

  • If it is a single selection only Listbox, please check the following solution for reference.

Set the OnChange property as below

 

If(!IsEmpty(Filter(Test3,Country1 in tem2.Country)),Reset(ListBox1))

 

  • If it is multiple selections allowed Listbox.

Actually, it can’t be achieved that you want to automatically deselect the most recently selected item in a List Box. The final result shown in Listbox is a table, however, you can only have one default selected item in the Default property of the Combo Box. If you need multiple selected items please use the Combo Box control. What’s more, Combo Box can’t automatically deselect, you’d better add a button to achieve this.

First I create a collection tem2 to save every selected item in the ComboBox. Then there is a collection named Test3 to check if the most recently selected items have existed in it, if it does, remove it from the tem2. By putting tem2 into the DefaultSelectedItems property, the ComboBox will show as you expect

I have a Collection named Temp filled in the Combo Box which you can see as below:

  • Add a ComboBox and set the Items property as

 

 Collect(Temp,{Country:"China"},{Country:"Korea"},{Country:"Japan"},{Country:"Thailand"})​

 

  • Create a collection as the existing collection

 

 Collect(Test3,{Country1:"Korea"},{Country1:"Canada"})​

 

  • Add a button and set the OnSelect property as

 

ClearCollect(tem2,ComboBox1.SelectedItems);If(!IsEmpty(Filter(Test3,Country1 in tem2.Country)),Remove(tem2,ComboBox1.Selected))​

 

  • Add another button to reset the ComboBox, set the OnSelect property as 

 

Reset(ComboBox1)​

 

  • Set the DefaultSelectedItems property of the Combo Box as

 

tem2​

 

Best Regards,

Qi

 

View solution in original post

2 REPLIES 2
Super User III
Super User III

On the Items of the listbox try:

Filter(Datasource,Not(Column in CollectionName.Column))

------------

If you like this post, give a Thumbs up. Where it solved your request, Mark it as a Solution to enable other users find it.

Community Support
Community Support

Hi@pwrappr01,

Based on the issue that you mentioned, do you want to make the most recently selected item deselect in the Listbox if it already exists in a collection?

Could you please share more about your Listbox, is it multiple selections allowed or not?

  • If it is a single selection only Listbox, please check the following solution for reference.

Set the OnChange property as below

 

If(!IsEmpty(Filter(Test3,Country1 in tem2.Country)),Reset(ListBox1))

 

  • If it is multiple selections allowed Listbox.

Actually, it can’t be achieved that you want to automatically deselect the most recently selected item in a List Box. The final result shown in Listbox is a table, however, you can only have one default selected item in the Default property of the Combo Box. If you need multiple selected items please use the Combo Box control. What’s more, Combo Box can’t automatically deselect, you’d better add a button to achieve this.

First I create a collection tem2 to save every selected item in the ComboBox. Then there is a collection named Test3 to check if the most recently selected items have existed in it, if it does, remove it from the tem2. By putting tem2 into the DefaultSelectedItems property, the ComboBox will show as you expect

I have a Collection named Temp filled in the Combo Box which you can see as below:

  • Add a ComboBox and set the Items property as

 

 Collect(Temp,{Country:"China"},{Country:"Korea"},{Country:"Japan"},{Country:"Thailand"})​

 

  • Create a collection as the existing collection

 

 Collect(Test3,{Country1:"Korea"},{Country1:"Canada"})​

 

  • Add a button and set the OnSelect property as

 

ClearCollect(tem2,ComboBox1.SelectedItems);If(!IsEmpty(Filter(Test3,Country1 in tem2.Country)),Remove(tem2,ComboBox1.Selected))​

 

  • Add another button to reset the ComboBox, set the OnSelect property as 

 

Reset(ComboBox1)​

 

  • Set the DefaultSelectedItems property of the Combo Box as

 

tem2​

 

Best Regards,

Qi

 

View solution in original post

Helpful resources

Announcements
New Badges

New Solution Badges!

Check out our new profile badges recognizing authored solutions!

New Power Super Users

Congratulations!

We are excited to announce the Power Apps Super Users!

Power Apps Community Call

Power Apps Community Call: February

Did you miss the call? Check out the Power Apps Community Call here.

Top Solution Authors
Top Kudoed Authors
Users online (73,480)