Need help on Cell flip up and down

Hello All,

Please help me to understand or knime flow to flip the cell values up an down for each cell for example as per the below, i want to flip the Validation -2 column cells up and down, first cell with second , 3rd with fourth simultaneously to all cells , Need your support and help.

String String
Validation - 1 Validation - 2
/650 blank
blank
/324 blank - Cell 3
100000
/324 blank
/630 blank - Cell 6
50000
/324 blank
60000
/3AM blank
50%
1 Like

Hello @Madhu_Sudhan,

Interesting problem! Initial thoughts would be that you are essentially switching
Row0 with Row1, Row2 with Row3, etc…

If we say Row0 is n, then we switch it with n+1, and swap values based on even or odd.

Row Indeces are 0-indexed so we can use that with modulo to check if odd, then we set it to previous value, otherwise if even set to next rows value.

Expressions code:

if($[ROW_INDEX] % 2 == 1, $["column2", -1], $["column2", 1])

This works, but I did not handle the edge case if you end up with an odd amount of rows. If you look at the image the 7 is replaced with missing. You will need to decide how you handle that edge case if you want to keep it there or just replace it with missing.

TL

2 Likes

Why not use the ag Column node?

2 Likes

thank you so much for your kind help sir :slight_smile: my all purpose was flip cells even with odd and value consisted cell , when my is completed amount for respective cells were not place one correct row cell, it is always placing one row or cell below. so empty should replace against with value cell.

1 Like

hi sir , thank you for your kind help , however column lag is not helping , thats why i have asked here :slight_smile: thanks again :slight_smile:

1 Like

Sorry if I am not understanding, but you are saying that if we are switching the cell with a missing value, don’t switch, but rather just keep the original value it had?

Try the code below for Expression node:

if($[ROW_INDEX] % 2 == 1, $["column2", -1] ?? $["column2"], $["column2", 1] ?? $["column2"])

Now it just keeps the original value if the value being swapped is missing:

1 Like