Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

IF statement, that can return 2 values if the condition is true

Hello;

I am trying to create an IF statement, that can return 2 values if the condition is true

for example:

if(1=1 , 'true1' and 'true2' , 'false')

appreciate any help.

thanks

Kumar


7 Replies
robert_mika
Master III
Master III

IF statement can only return one value

Can you explain what are you trying to achieve?

Your condition can be multiple

if(1=1 and 2=2...



MarcoWedel

Hi,

how do you plan to use those values?

Please provide an example.

regards

Marco

Not applicable
Author

Hello Robert:

I am trying to achieve the following

if( Currency = 'Eur', '101',
if( Currency = 'Eur', '202',

if(Currency = 'AUD', '606',
    
if(Currency = 'PLN', '201',
    
if(Currency = 'MXN', '301',
    
if(Currency = 'NTD', '603',
    
if(Currency = 'CNY', '601',
    
if(Currency = 'KRW', '602',
    
if(Currency = 'JPY', '607',               
     )))))))))  
as "Division"

For value where the Currency is Eur I would like to have 2 divisions (101 & 202) so as to be connected to

another table.


MarcoWedel

Hi,

you could try

Subfield(Pick(Match(Currency, 'Eur','AUD','PLN','MXN','NTD','CNY','KRW','JPY'),'101-202','606','201','301','603','601','602','607'),'-') as Division

instead

hope this helps

regards

Marco

Anonymous
Not applicable
Author

Maybe use a many-to-many table instead.

Table:

LOAD * INLINE [

Currency, Division

Eur, 101

Eur, 201

AUD, 606

...

];

MarcoWedel

maybe like this:

QlikCommunity_Thread_163693_Pic1.JPG

QlikCommunity_Thread_163693_Pic2.JPG

table1:

LOAD *,

    Subfield(Pick(Match(Currency, 'Eur','AUD','PLN','MXN','NTD','CNY','KRW','JPY'),

                              '101-202','606','201','301','603','601','602','607'),'-') as Division

Inline [

ID1,Currency

1,MXN

2,Eur

3,PLN

4,MXN

5,MXN

6,AUD

7,MXN

8,KRW

9,CNY

10,MXN

11,AUD

12,MXN

13,MXN

14,Eur

15,CNY

16,JPY

17,NTD

18,MXN

19,JPY

20,JPY

21,MXN

22,JPY

23,AUD

24,JPY

25,MXN

26,MXN

27,CNY

28,NTD

29,JPY

30,MXN

];

table2:

LOAD *,

    RecNo() as ID2

Inline [

Division

101

202

606

201

301

603

601

602

607

];

hope this helps

regards

Marco

Not applicable
Author

Thanks Marco, appreciate the help and for your time.