Else if statement

Hi everybody,

Wondering if someone can help me to solve this?
No matter what Boolean parameter is, result is always the same. What I’m missing?

My formula is: If(w=“true”, w1, if(x=“true”, x1, if(y=“true”, y1, “Output is Empty list”)))

Thanks

well you can do it either way as shown in the screen shot. I believe you missed and typed wrong the return code.
image
for the first case, you cant feed empty list and everything will be empty list no matter the condition.

You should return ‘z’, not ‘na’.

Something weird is going on here.
Did the same as per your example, but it is showing me an error.

It is not working either.
I’m playing around with the lists. Maybe I need to do something different then? I have 3 different inputs (lists) and based on the boolean parameter the output is to be shown accordingly. In my case return value suppose to be Empty list, not a null value.

Change z== to z=

Anton, thanks. It worked.
The only thing I worry about is the output, when all 3 Boolean parameters are set to false.
For example: If my ‘w’ value is True, the output is the list 1…5. That’s fine. But when set this to false later on, the output is still the same - 1…5. I need an Empty list instead.

Do you have an idea how to upgrade this?

I think I just found a solution.

Anyways, thank you @Anton_Huizinga & @stillgotme for your feedbacks. I appreciate that.

The problem is your lists don’t match in length. So you’ll only get partial returns:
image

The trick is to create a list of all your options and return the index instead.
image

1 Like

Nick, thanks.
That’s the next level. I need to work way more harder to catch you up. Haha

It’s basically what you have just in code block syntax.

a?b:c

a = conditional statement (or boolean)
b = true value
c = false value
1 Like

It’s really time saver. And there is no way to miss any text or symbols. Thanks!

Hi @Nick_Boyts, @Anton_Huizinga, it’s been a while you helped me to understand and sort out some things with ‘else if statement’.

After some time I came back with a similar problem that I can’t solve.
@Nick_Boyts, I followed your syntax that you have showed me before, but I’m facing the same problem with empty list and have no idea how to fix this using this kind of syntax.

So no matter which boolean is true or false I’m always getting Empty List. I should get Empty list ONLY when all booleans are set to FALSE.

Any ideas? Thanks.

//Case Sensitive?
CASE;
A1;
B1;
C1;
D1;
E1 = [];
//String Contains
A = String.Contains(input1,input2,CASE);

//String Does not Contain
B = !A;

//String Starts With
C = String.StartsWith(input1,input2,CASE);

//String Ends With
D = String.EndsWith(input1,input2,CASE);

A1?A:(B1?B:(C1?C:(D1?D:E1)));

You return an emty list (E1).
The mask must be a list of booleans, not an empty list.

1 Like

Thank you for pointing out my mistake.

Just changed the E1 to false instead of an empty list. Now works like a charm.