Compare two lists for "Only When"

I looked in the forum and it seems that for the last 4 years, there’s been (a few) requests to compare lists. It’s a little weird that there is no way to do this. There are some suggestions on how to compare for “true”, but I can’t find an efficient way to do this for “false”.

That is, I have a list of options I need to compare and execute a workflow “only when” they don’t match. No simple way to do this as, while there is a “contains list”, there is no “does not contain list”.

I ended up doing a “format as text” after sorting, which seems insane to me.

Is there a better way?

I think intersect should do the trick.

So:
list A: 1, 2, 3 and list B: 2, 3, 4
list A intersect with list B: 2, 3
It is not the same as A or B, so no match.

list A: 1, 2, 3 and list B: 2, 3
list A intersect with list B: 2, 3
It is the same as B, so A contains B.

list A: 2, 3 and list B: 1, 2, 3, 4
list A intersect with list B: 2, 3
It is the same as A, so B contains A.

I tried this, but… how do I compare the result? I need the “negative”, so getting the intersected list doesn’t help…?

as a condition, not getting the list

only when (List A intersect with List B) is not List A)

Unfortunately “contains list” is an option but “does not contain list” is not.

Please read what he wrote. his solution is not using “contains list” and is not using “does not contain list.”

@code-escapee already implemented it that way. It doesn’t use doesn't containt list. It uses list equality using is not.

I accept I may be missing something but…

There is no option for “is” or “is not” on a list. Only “Contains list”.

There is no way - that I can see - to see if a list is equal to another list, otherwise I wouldn’t need the intersect… no?

I think you gotta escape out of the last “)”

Nope… I turned off the new expression editor just in case, but that’s the point. If there was an “is” for lists, I wouldn’t need to intersect them.

Were you asking if a better way or if an “is” for lists because now I’m confused.

Someone posted a way to do it with intersect and count, but the message has disappeared. In the end I did it like this…

To be clear, there is no “is” or “is not” for list comparison. There is a “contains list” but no “does not contain list”. This makes it tricky to use in a workflow with “only when” .

I think there should be a way to compare lists for equality or inequality, but meanwhile, the above works if someone needs it.

1 Like

Yeah, that was me, @RPSM. Sorry about that, but I wasn’t sure I had thought it through correctly, so I deleted the reply. I was just about to post something similar again, though, and here it is.

To the best of my knowledge, what you are looking for (an easy way to see if two lists match) doesn’t exist. I could be overthinking things here, but it seems like having the first part of a condition check to see if a count of the items in the first list is not equal to a count of the items in the second list would be ideal in your case because the condition would not need to progress if that is true, and your workflow would run. Then, add an or and check to see if the counts of the items in each list are equal and a count of the intersect is not equal to a count of one of the lists.

Ah, OK you disappeared so quick I didn’t get to understand it :grinning:

I used the minus in my solution. If the counts don’t match or if after removing the items in the second list, the result isn’t 0, then they aren’t the same (it’s an option set, so the possibilities are limited to the same for both).

I think that yours would also work, if the counts don’t match or if the intersect of the two lists doesn’t equal the count of either list, then they don’t match.

But… think about a list equality operator. :grinning:

1 Like

Yes. You are right. There is no is for lists. I actually meant this for list equality. A is B means A contains B is yes and A:count is B:count.

Which is great when you are doing a positive comparison, but cannot work for a negative comparison as is required for “only when”.

Solved now, and I think the “minus” solution is actually pretty “engineer”-sound (but an equality operator would be better).

1 Like

Would be nice if Bubble would focus on features like this (list comparisons), rather than silly AI roadmap items that are Investor focussed. (@fede.bubble)