Column Expression: If statement with and

I have 2 columns of data: 2018 sales and 2019 sales. I am using column expressions node to determine growth rate …round((column(“2019 revenue”)-column(“2018 revenue”))/column(“2018 revenue”),3)

I would also like to add an IF statement but I can’t figure out how to write it correctly…

if column(“2019 revenue”) > 0.0 AND if column(“2018 revenue”) = 0 then “1”
if else put growth rate calculation round((column(“2019 revenue”)-column(“2018 revenue”))/column(“2018 revenue”),3)

How do I write this in the Column Expressions node?

Hi @ahortonmilsig

Here is a good example for the if syntax

Cannot test it at the moment, but your example should be something like this:

if(column(“2019 revenue”) > 0.0 && column(“2018 revenue”) = 0)
{
1
}
else {
round((column(“2019 revenue”)-column(“2018 revenue”))/column(“2018 revenue”),3)
}

3 Likes

*tested now: should be == instead of =

The following works for me:
if(column(“2019 revenue”)> 0.0 && column(“2018 revenue”) == 0)
{
1
}
else {
round((column(“2019 revenue”)-column(“2018 revenue”))/column(“2018 revenue”),3)
}

6 Likes

Thank you so much, I really appreciate it.

2 Likes

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