Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

creating a new column using existing column

Hello,

I am having little bit of a difficulty trying to create a new column using if statement on an existing column

i am doing

     IF(NRTT_Plan='NEW,'RENEW','TRANSFER IN', 1,

     IF(NRTT_Plan='NEW,'TRANSFER IN',2,

     IF(NRTT_Plan='TERM',3,

     IF(NRTT_Plan='TERM' AND Member_Age='0.26', 4))) as Status_Flag,  

but this does not work. i tired putting them in parenthesis but only  IF(NRTT_Plan='TERM',3, is loaded into table and nothing else.


What am i doing wrong here. Please help me.



Thank you,

Syed.

16 Replies
krishnacbe
Partner - Specialist III
Partner - Specialist III

HI,

Can you please share some sample data.

vishsaggi
Champion III
Champion III

Try this may be:

  IF(Match(NRTT_Plan, 'NEW,'RENEW','TRANSFER IN'), 1,

  IF(Match(NRTT_Plan, 'TERM'), 2,

  IF(Match(NRTT_Plan, 'TERM') AND Member_Age='0.26', 4))) as Status_Flag, 

Anonymous
Not applicable
Author

Try

If(match(NRTT_Plan,'RENEW',1,

     if(match(NRTT_Plan,'TRANSFER IN'),2,

     if(match(NRTT_Plan,'TERM') AND Member_Age='0.26',4,3))) as Status_Flg

Anonymous
Not applicable
Author

If you don't move the TERM and Member Age logic above the regular TERM logic you will never get any number 4 statuses.

mjtaft2017
Partner - Creator
Partner - Creator

Syed,

Are you trying to put these into one and only one slot 1 - 4?  Because you have duplication.

In NRTT_Plan can there be only one of the values or multiple.

You could do it either of these ways, however you will get the same records meeting conditions 1 & 2

IF(NRTT_Plan='NEW' or NRTT_Plan ='RENEW' or NRTT_Plan ='TRANSFER IN', 1,

     IF(NRTT_Plan='NEW' or NRTT_Plan ='TRANSFER IN',2,

     IF(NRTT_Plan='TERM' AND Member_Age='0.26', 4,

     IF(NRTT_Plan='TERM',3 )))) as Status_Flag

IF(Match(NRTT_Plan,'NEW,'RENEW','TRANSFER IN')>0, 1,

     IF(Match(NRTT_Plan,'NEW,'TRANSFER IN')>0, 2,

     IF(NRTT_Plan='TERM' AND Member_Age='0.26', 4,

     IF(NRTT_Plan='TERM',3 )))) as Status_Flag

The only difference between your first condition and second seems to be that #1 has 'RENEW' in it

Without knowing your intention - it is hard to give you direction.  Its possible that you want the same record to appear with a value 1 and 2.  Only you know that answer.

You did need another right paren on your IF statement -- you had 4 conditions so you needed 4 right parens ')' at the end.

MarcoWedel

please post some sample values and your expected result as well.

thanks

regards

Marco

Not applicable
Author

this four flags are for

1= active

2=new

3=Termed

4= termed at the age of 26

1 which is "Active' can be New members, renewed members and Transfer in

2 which is 'New' can be members that just signed up and are new to the plan. so they can only be New or Tranfer in as renwed members are already established and cannot be considered new.

3 is termed  and 4 is Termed at age 26.

so yes, #2 will be same as #1 - Renewed members

i followed the steps that Wallo Atkinson suggested but the new field is not generated in the resulting column. Will try your method and see if it works.

Thank you,

Syed.

Not applicable
Author

i tried your  both approaches but non were able to load filed 'New' for me. 

Not applicable
Author

please find the sample data in the attachment. I need four groups but no matter how i try it, the resultant column has only 3. I am not able to load field 'New' in it.