If statement wrong output

Hello,

I have a problem with 2 lists.
List A has 4 items en list B has 6.
If “true” I expect to get list A and if “false” list B. Somehow in both it return list A.

Does anybody have a clue ?

Best regards, Fred

The If node always returns the same length, using the shortest list’s length. So in this case, when it is false, it returns only the first 4 items of the false list.

Try using ScopeIf, it will return the entire false list.

ScopeIf is a little more complicated than that.
This question has been asked and answered dozens of times already. Please search the forum before asking for help.

Thanks Kenny, but with ScopeIf it crashes.

My appologies Nick, but I thought I couldn’t find anything similar.
Just now I found out that it didn’t give list A for both results, but list A for “true” and the first 4 items of list B for “false”.
Because of the identical display of references I could not see the difference. I solved it by using [transpose] and [remove nulls].

That’s actually a clever solution but you should look into the list/index solution for getting the correct output. I’m guessing transpose won’t work as well if you have a more complex list structure.

This is my personal favorite method for dealing with this type of issue:

rslt = [lstA, lstB][test ? 0 : 1];

4 Likes

Thanks Jacob,
Works like a charm.
Fred

1 Like