Skip to main content
Announcements
Global Transformation Awards! Applications are now open. Submit Entry
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Using For next loop i want to remove column C2,C3,C4 record when C1 is even.other wise if C1 is odd then store data as it is.

[TblRecords]:

load * Inline

[

C1,  C2,  C3,  C4

1,  a1,  b1,  c1

2,  a2,  b2,  c2

3,  a3,  b3,  c3

4,  a4,  b4,  c4

5,  a5,  b5,  c5

6,  a6,  b6,  c6

7,  a7,  b7,  c7

8,  a8,  b8,  c8,

9,  a9,  b9,  c9,

10,  a10, b10, c10

];

I have table. I want to Null/Remove column C2, C3, C4 Record when C1 column is even.

4 Replies
jonathandienst
Partner - Champion III
Partner - Champion III

Is this what you are looking for?

LOAD C1, C2, C3, C4

FROM ....

Where Mod(C1, 2) = 0;

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein
Anonymous
Not applicable
Author

actually  I want to return

:

C1,  C2,  C3,  C4

1,  null,  nullnull

2,  a2,  b2,  c2

3,  nullnullnull

4,  a4,  b4,  c4

5,  nullnullnull

6,  a6,  b6,  c6

7,  nullnullnull

8,  a8,  b8,  c8,

9,  nullnullnull

10,  a10, b10, c10

OmarBenSalem

load C1, if( Mod(C1, 2) = 0, C2, null()) as C2

,if( Mod(C1, 2) = 0, C3, null()) as C3

,if( Mod(C1, 2) = 0, C4, null()) as C4

;

load * Inline

[

C1,  C2,  C3,  C4

1,  a1,  b1,  c1

2,  a2,  b2,  c2

3,  a3,  b3,  c3

4,  a4,  b4,  c4

5,  a5,  b5,  c5

6,  a6,  b6,  c6

7,  a7,  b7,  c7

8,  a8,  b8,  c8,

9,  a9,  b9,  c9,

10,  a10, b10, c10

];

result:

Capture.PNG

rubenmarin

Hi, Even() or Odd() function can help:

LOAD C1,

     If(Even(C1), C2, Null()) as C2,

     If(Even(C1), C3, Null()) as C3,

     If(Even(C1), C4, Null()) as C4