Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

How to create a column using multiple if condition

Hi All,

How to create a column(G) using multiple if condition .

Condition: S='a' and P<=3,'Y' or else 'N'

                   S='b' and P<= 5, 'N' or else 'O'

                  

Source data:

S

P

a

2

a

2

b

3

b

5

Required output:

S

P

G

a

1

Y

a

4

N

b

6

O

b

5

N

Thanks,

Krishna

3 Replies
sunny_talwar

How is Column P changing? For the column G, try this

If(S = 'a',

     If(P <= 3, 'Y', 'N'),

If(S = 'b',

     If(P <= 5, 'Y', 'O'))) as G

darrell_tobin
Creator
Creator

Hi Try this:

=if(

S= 'a' and P<= '3' , 'Y',

    If(S= 'a' and P> '3', 'N',

    If(S= 'b' and P<= '5', 'N',

  

    '0'

    )))

Please like or mark if correct 🙂

MarcoWedel

Hi,

one solution could be also:

QlikCommunity_Thread_285443_Pic1.JPG

table1:

LOAD *,

    Pick(Match(S,'a','b'),

          If(P<=3,'Y','N'),

          If(P<=5,'N','O')) as G;

LOAD Pick(Ceil(Rand()*2),'a','b') as S,

    Ceil(Rand()*8) as P

AutoGenerate 10;

hope this helps

regards

Marco