4 Replies Latest reply: Feb 5, 2014 1:18 AM by Michael Gardner

# Splitting of -ve and +ve values in 2 columns

Hi All,

How we can calculate -ve and +ve values in 2 columns.

e.g.         A       B      C

5       10      5

5        3       -2

100       170     70

100       30     -70

201     501     300

o/p

A             D       E

5              5      -2

100           70     -70

201         300    -

Thanks,

Ravi

• ###### Re: Splitting of -ve and +ve values in 2 columns

See attached qvw.

• ###### Re: Splitting of -ve and +ve values in 2 columns

Can you explain how the if(mod(RowNo(),2,C) and if(not mode(RowNo(),2,C) function works to split out column c?

Would this work if the data was like below?

INLINE [

A, B, C

5, 10, 5

5, 3, -2

5, 4, -3

100, 170, 70

100, 30, -70

201, 501, 300

];

• ###### Re: Splitting of -ve and +ve values in 2 columns

I liked Gysbert's soloution, however FYI: just an other soloution if you want, please check below script

//---------------------------------------------------------------------------------

Data_Temp:
A, B, C
5, 10, 5
5, 3, -2
100, 170, 70
100, 30, -70
201, 501, 300
]
;
//---------------------------------------------------------------------------------
Map_Data_D:
Mapping LOAD A, C Resident Data_Temp Where C>=0;
Map_Data_E:
Mapping LOAD A, C Resident Data_Temp Where C<0;
//---------------------------------------------------------------------------------
Data: