Counting a Value in a LIST set in a State

I have a LIST which is a STATE of a element. I am adding the value of a input field to that List every time a button is pressed. I have a Icon which I need to setup a Conditional Rule which would change the icon depending on if the value is the list 1 time or 2 or more times. I cant figure out how take a value and check it against the LIST in the STATE and see if the count is equal or larger then 2.

If the value is in the list 1 time then the conditional rule should be X
If the value is in the list 2 times or more then the conditional rule should be Y

If its a list of database things, you can do

Search for thing : filtered (criteria: field is value) : count

or

list : filtered (criteria: field is value) : count

Thank you @mishav, it seems like when you use the :plus item function to a list it will discard the item if it is a duplicate, any way to change that?

Hi @shawn.chaudhery, sorry, my previous reply I missed reading where you say you have the value of an input field. That workaround for duplicate counting won’t work.

Bubble’s list functions which create a new list, including :plus item, :filtered, etc always remove duplicate items. It is a nuisance when you do want duplicates.

One workaround is to use Javascript expressions to build the new list or check for duplicates.

Another workaround is to have a list of unique database rows, the field values can be identical without the list having duplicates.

This topic was automatically closed after 70 days. New replies are no longer allowed.