Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

Announcements
QlikView Fans! We’d love to hear from you.
Share your QlikView feedback with the product team… Click here to participate in our 5-minute survey.
Rules, plus terms and conditions, can be found here.
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

ali_hijazi
Honored Contributor

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

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

Community Browser