nested IF statements error

Hi Team,

I am trying to execute the below if else condition with the attached data. but it is throwing
Sample data.xlsx (323.7 KB)
an error. Please help me in resolving the error.

*Code
if((column(“Purchase Order”)==“0” || column(“Purchase Order”)==“000000000000”) & (getYear(column(“DocDateType”)!=“1900” || getYear(column(“CreationDateFormat”)!=“1900”) )))
{
if(getYear(column(“321DateFormat”)!=“1900”))
{
column(“CDF&321”)
}
else
{
column(“CDF&101”)
}
}
else if((column(“Production Order”)==“0” || column(“Production Order”)==“000000000000”) & (getYear(column(“DocDateType”)!=“1900” ||getYear(column(“CreationDateFormat”)!=“1900”) )))
{
if(getYear(column(“321DateFormat”)!=“1900”))
{
column(“DD&321”)
}
else
{
column(“DD&101”)
}
}
else
{
“99999”
}

Error
image

Attached the data:

The nesting of your parentheses is wrong in multiple places. One examples:

if(getYear(column("321DateFormat")!="1900"))

Note that the != comparison is inside the getYear(...) call, so you’ll either call getYear(true) or getYear(false). To fix your code, make sure that all calls to that function look like getYear(column("XXX")) with two closing parens after the column name.

– Leo

1 Like

I think a good approach to debug is to break things down into simple if-then relations.

Start with the outer and increase the complexity step by step.
Sometimes it’s better to use just two Nodes for the tasks

Hi @leo_woerteler

I verified the same but no use

This works for me:

if((column("Purchase Order")=="0" || column("Purchase Order")=="000000000000") & (getYear(column("DocDateType"))!="1900" || getYear(column("CreationDateFormat"))!="1900")) {
    if(getYear(column("321DateFormat"))!="1900") {
        column("CDF&321")
    } else {
        column("CDF&101")
    }
} else if((column("Production Order")=="0" || column("Production Order")=="000000000000") & (getYear(column("DocDateType"))!="1900" || getYear(column("CreationDateFormat"))!="1900")) {
    if(getYear(column("321DateFormat"))!="1900") {
        column("DD&321")
    } else {
        column("DD&101")
    }
} else {
    "99999"
}
2 Likes

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