IN operator in Column Expression node

Another Help.

Do you know how to use de IN operator in Columns Expressions?
Similar to LIKE

Example:

**Instead of **
if (column(“@CFOP_Ficha3”) == “1409”)
{
column(“qCom”)
}
else if (column(“@CFOP_Ficha3”) == “5405”)
{
-1*column(“qCom”)
}

To something like
if (column(“@CFOP_Ficha3”) IN (“1409”,“5405”…)
{
column(“qCom”)
}

Hi,
JavaScript does not have an IN operator, but you can do it like this:

["A", "B", "C"].indexOf(column("yourcol")) >= 0

Kind regards,
Alexander

2 Likes

Hi Alexander,

I tried something like this:

if (["1409", "5405"].indexOf(column("@CFOP_Ficha3")))
{
    "yes"
}

But has you can see, for one rule, it returned missing.
What I did wrong?

Hi,
you are missing the >= 0 in the expression. Right now the if is “truthy” if the value returned by indexOf is anything but 0. This is the case when the value is not in the list at all (indexOf returns -1) or when it is 1 for the 5405. The 1409 is at position 0 in the list and therefore the if is false in that case.
Kind regards,
Alexander

Hi Alexander

Sorry the late to respond.
It worked.

Now I understand.
It’s because de “indexof” return a number.

Thank you so much.
Have teach me a lot.

1 Like

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