Column Expressions if else behaviour

Hi all
I’m learning to use if else in Column Expressions and have noticed some behaviour that I don’t understand…

Here I use the format if() true, false and get the result 0.1336 on the first row

Here I use the format if() x else x and get the result 0.0

The correct result should be 0.1336 as the “Secteur” is not “MOULAGE”.
But most of the references to if else I see use the second format.

It seems that the problem is with my condition as I get the same results even when I put the ‘correct’ “Secteur”.

But if I use the second format (with else) I always get the false result and if I use the comma I always get the true result.

Or are these reversed somehow in the two statements??

Can anyone see where I’m going wrong?

Much appreciated.
Zx

1 Like

OK I’ve resolved the condition by using @izaychik63 suggestion

So now I can test the outcomes and yes if I use the else I have the correct result but if I use the comma I have a reversed result.

I don’t know now where I saw the statement using a comma - but I won’t be using it now!

2 Likes

Hi @zedleb,

glad you figured it out. I usually check this page when using Column Expressions :slight_smile:
https://www.w3schools.com/js/js_if_else.asp

Br,
Ivan

3 Likes

Thanks @ipazin
I’m not at all familiar with JavaScript but I think I need to get into it to be able to use snippets etc. The w3schools was on my list for tutorials :slight_smile:

2 Likes

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.