Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

Announcements
QlikWorld 2020: Join us May 11 - 14, 2020 in Phoenix, AZ. Register early and save $400. Learn More
Not applicable

how to create a new column by using the the existing column

Hi team,

I have a field called status which contains the code from 1 to 10.

i need to create a new column called group based on these codes.

if code is 1 or 2 then it should be new

if code is 3 to 5 it should be old

if code is other then above then it should be NA

can you help me to achieve this.

thanks

7 Replies
marcarreras
Valued Contributor

Re: how to create a new column by using the the existing column

Hi,

try with:

LOAD *, if(code<3, 'new', if(code<6, 'old', 'NA')) as groupcode

FROM yoursource;

Marc

gabriel_kirst
Contributor III

Re: how to create a new column by using the the existing column

Try something like this.

LOAD

     code

     if(code >=1 and code <= 2, 'New', if(code >=3 and code <=5, 'OLD', 'NA'))

Resident your_table

Regards,

Gabriel

Partner
Partner

Re: how to create a new column by using the the existing column

load * , if (code <3, 'new', if(code <6 , 'old', 'n/a')) as groupcdoe resident your_table

drop your_table

I can walk on water when it freezes
chinnakatikisg
Valued Contributor

Re: how to create a new column by using the the existing column

Hi,

Simple if caluse will work.

if(code >=1 and code <= 2, 'New', if(code >=3 and code <=5, 'OLD', 'NA'))


BR,

Chinna

Not applicable

Re: how to create a new column by using the the existing column

thank you, i got it

Not applicable

Re: how to create a new column by using the the existing column

thanks

Not applicable

Re: how to create a new column by using the the existing column

thank you