One Star

How to check if a column is not empty when another is not empty

Hello team,
Do you have an idea to help me please:
i import a file with multiple column.
Column 1 must have a value if the Column 2 is not empty
same for the Column 3, but column 2 and 3 are optional, the file can have only 1 column with value
i tried
(!Relational.ISNULL(row3.Level_2_cd) && !row3.Level_1_cd.equals("")) ==
(!Relational.ISNULL(row3.Level_3_cd) && !row3.Level_2_cd.equals(""))
but that report me an error due to the fact the column 1 is not empty
and that in a tmap
thanks for your help
7 REPLIES
One Star

Re: How to check if a column is not empty when another is not empty

Hi
First, where do you want to use this condition? What's your essential requirement to do this? To filter rows?
Regards,
Pedro
One Star

Re: How to check if a column is not empty when another is not empty

i used this condition in a tmap
One Star

Re: How to check if a column is not empty when another is not empty

here is a screenshot
One Star

Re: How to check if a column is not empty when another is not empty

Hi
In fact, I don't understand your filtering rule.
Sorry.
Regards,
Pedro
One Star

Re: How to check if a column is not empty when another is not empty

it's not easy to explain.
in the screenshot, on the left my imported file
on the right mut ouput file (out1) and rejected file (reject)
i will put in reject file all rows with an level_1_cd empty while level_2_cd full
One Star

Re: How to check if a column is not empty when another is not empty

hello,
i found why, just an issue with my expression.
(!Relational.ISNULL(row3.Level_2_cd) && !row3.Level_1_cd.equals("")) && (!Relational.ISNULL(row3.Level_3_cd) && !row3.Level_2_cd.equals(""))
instead of
(!Relational.ISNULL(row3.Level_2_cd) && !row3.Level_1_cd.equals("")) == (!Relational.ISNULL(row3.Level_3_cd) && !row3.Level_2_cd.equals(""))
Sorry for your time
One Star

Re: How to check if a column is not empty when another is not empty

Hi
Great! Glad to hear you have fixed it.
Regards,
Pedro