I want to use nested if in Column expression node for below example.
if Column A is blank then Column B
else
if Column B is blank then Column C
else
if Column C is blank then Column D
else
if Column D is blank then Column E
else
Column A
Kindly help me with the syntax to be used in KNIME Column Expression node.
If in Column A any row is blank then consider Column B for that row
else
If in Column B any row is blank then consider Column C for that row
else
If in Column C any row is blank then consider Column D for that row
else
Column A
When you say it’s not working are you writing out to a new column for the results of the expression in the right data type (string, integer etc)? Is it also possible that Column E needs to be accounted for in your logic? Also, do you have any Missing values, rather than blank values?
As they say, if you have an example or sample of your data to show that could really help in troubleshooting your issue.
Hey thanks for your update.
I am looking at something else
For example, I have 100 records,
in 1st record value is in MG L07 ID to MG L02 ID,
2nd record data is in MG L06 ID to MG L02 ID --(L7 is blank),
3rd records data is in MG L05 ID to MG L02 ID–(L7 & L6 is blank), so on
So i need output
1st Record it should capture L7
2nd record L6
3rd record L5
and so on.
Hi @JatinShah,
I’m trying to understand the rational behind your nested if expression. Are you looking for the first non blank column starting from A all the way upto E?
Because that’s not how I would interpret your expression, which is the same as how @TardisPilot coded it in the solution.
If you want the first non blank column you could indeed use a rule engine node for this too. It would look like this, where the first row which is gives a TRUE will be used (and the rest is skipped).
NOT MISSING $ColumnA$ AND NOT $ColumnA$ = "" => $ColumnA$
NOT MISSING $ColumnB$ AND NOT $ColumnB$ = "" => $ColumnB$
NOT MISSING $ColumnC$ AND NOT $ColumnC$ = "" => $ColumnC$
NOT MISSING $ColumnD$ AND NOT $ColumnD$ = "" => $ColumnD$
TRUE => $ColumnE$
Hi @JanDuo,
I need to check in case as per below scenario
1st Record - If value is missing in MG L7, then consider L6.
If value missing in L7 & L6, then consider L5.
If value missing in L7,L6 & L5, then consider L4.
If value missing in L7, L6,L5 & L4 then consider L3.
If value missing in L7, L6,L5,L4 & L3 then consider L2.
If value missing in L7, L6,L5,L4, L3 & L2 then consider L1.
and so on
Kindly let me know if any further details required.
For each record, I have 8 columns. 1st column is Global ID and rest 7 columns has value
So for each record it should give the output from the 7 columns, i.e out of 7 columns which column has the last data.