Column Expression with IF

HI Everyone

I am having difficulties on the Column expressions, I don’t have any Java knowledge at all, I had a hard time understanding the structure on the Column expression.

What I wanted to do is as below, but the column expression do not let me go through, any guide or tips here would be greatly appreciated.

I have following columns, may not necessary, but I tried to build these supporting columns for easier execution.

Background
“StyleColor” = contain the Style color, some starts with “GC”, some don’t
“first2digit” = take the first 2 digit from “StyleColor”, Rows with value “GC” are what we looking for here.
“StyleColorLength” = Count the length of character in Column “StyleColor”, a supporting column here.

My goal:
//If the first 2 digit from the Column “Style Color” is “GC”,
AND
column “StyleColorLength” value is >=14, then we take the first 8 digit from the left off Column “Style Color”
Otherwise we pick the Style Color.

Here is my tryout [Failed]

if(AND(column(“first2digit”) == “GC”), column(“StylecolorLength”) >= 14)
{left(column(“Style Color”),8)}
Else{
column(“Style Color”)
}

I think it would’ve been helpful if you provided the workflow with data. At the very least you could’ve mentioned what specific error messages you were getting. Just saying “the column expression do not let me go through” doesn’t really give us much to work with.

if(AND(column(“first2digit”) == “GC”), column(“StylecolorLength”) >= 14)
{left(column(“Style Color”),8)}
Else{
column(“Style Color”)
}

You’re on the right track, but I see a number of issues here:

  1. AND should not be uppercase. Use the function drop down menu and you’ll see this. If you try to evaluate the expression as written, you’ll get an error message saying that there’s no AND function.
  2. Else should be all lowercase. The error message that results here is a little cryptic.
  3. In your expression you refer to a column called StylecolorLength, but in your Background section you refer to the same column as StyleColorLength. The error message lets you know that these are not interchangeable. Which is the correct one?
  4. In your expression you refer to a column called Style Color, but in your Background section you refer to the same column as StyleColor. Again, these are not interchangeable. Which one is correct?

Address these issues and your expression should work fine.

2 Likes

HI Elsamauel

Thanks for the reply, Sorry about missing the error message earlier, i have made the change as you suggested, and got the error message below. (Column “StyleColor” should be “Style Color” with space)

Revised entry:

if(and(column(“first2digit”) == “GC”), column(“StylecolorLength”) >= 14)
{left(column(“Style Color”),8)}
else{
column(“Style Color”)
}

Error msg:

Errors in code. Please fix the expression.
Expected an operand but found error
if(and(column(“first2digit”) == “GC”), column(“StylecolorLength”) >= 14)
^ at line 1 at column 33

Which part goes wrong please?

It’s hard to say what’s wrong, since you haven’t shared your workflow or data.

My advice would be to check your quotation marks.

If your expression looks like this, then the quotation marks are the wrong type.

Anything inside of quotation makes should be pink/red

2 Likes

HI Elsamuel

Sorry, that is the data from my work, so i am not sure if it is appropriate to share it in public.

Your comment is correct, somehow, i updated the quotation mark and the entry could go through with the cutie greenlight now.

Thanks very much

1 Like

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