7 Replies Latest reply: Jun 10, 2016 10:01 AM by Sunny Talwar

# If statement where buckets may overlap

 CUS ID CC Sav Cur 1 1 1 1 2 1 0 0 3 0 0 1 4 0 1 1 5 0 1 1 6 0 1 0 7 0 1 0 8 0 1 0 9 0 1 1

Logic is something like,

if CC = 1 then 'Cards',

if Sav = 1 and Cur = 1, 'Marked'

Please can you help with the correct IF statement for this. Some CUS ID's should end up with 2 values; ie they fall into both the Cards and Marked bucket

Thanks

Stu

• ###### Re: If statement where buckets may overlap

You need to create a link table, like

'Cards' as NewField

RESIDENT YourTable

WHERE CC =1;

CONCATENATE

'Marked' as NewField

RESIDENT YourTable

WHERE Sav=1 AND Cur =1;

• ###### Re: If statement where buckets may overlap

thanks

• ###### Re: If statement where buckets may overlap

May be like this:

If(CC = 1 and Sav = 1 and Cur = 1, 'Both',

If(CC = 1, 'Cards', If(Sav = 1 and Cur = 1, 'Marked')))

• ###### Re: If statement where buckets may overlap

Something like this?

• ###### Re: If statement where buckets may overlap

Hi Sunny, thanks for the help but i needed multiple values for those Customers who appear more than once

Thanks for helping anyway.

• ###### Re: If statement where buckets may overlap

Sounds good

• ###### Re: If statement where buckets may overlap

use this

if(len(cards)<>0 and len(marked),1,0) as flag;

if( CC = 1, 'Cards') as cards,

if (Sav = 1 and Cur = 1, 'Marked') as marked

;

load * inline [CUSID,    CC,    Sav,    Cur

1,    1,    1,    1,

2,    1,    0,    0,

3,    0,    0,    1,

4,    0,    1,    1,

5,    0,    1,    1,

6,    0,    1,    0,

7,    0,    1,    0,

8,    0,    1,    0,

9,    0,    1,    1];

flag is 1 for not empty cards and not empty marked