Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Problem with the If condition

Hi All,

I have this if condition, but it's not working for some reason. Can anyone tell me what am I missing here?

Load if((Country = 'United States of America' or Country ='China' or Country ='Taiwan' or Country ='Germany (Federal Republic of)' or Country ='Netherlands') and ( "Status"= 'Allowed' or "Status"='Granted')

and( Company = 'ABC')

and  (DFAnalysis = 'Low')

AND  (IFSCORE >= 3), 'LOW', 'NA')  as Stage,   ID

Resident Temp;

Thank you.

10 Replies
Not applicable
Author

Hi,

Please try wildmatch in place of  "(Country = 'United States of America' or Country ='China' or Country ='Taiwan' or Country ='Germany (Federal Republic of)' or Country ='Netherlands')

"

like

if(wildmatch( Country, 'United States of America' ,'China' ,'Taiwan' ,'Germany (Federal Republic of)','Netherlands') >0

and wildmatch(Status,'Allowed','Granted')>0 .........

jagan
Luminary Alumni
Luminary Alumni

Hi,

Try this

Load IF( Match(Country, 'United States of America', 'China', 'Taiwan', 'Germany (Federal Republic of)', 'Netherlands')

AND Match(Status, 'Allowed' , 'Granted')

AND Company = 'ABC'

AND  (DFAnalysis = 'Low'),

     IF(SCORE >= 3, 'LOW', 'NA'))  as Stage,  

ID

'

'

'

Hope this helps you.

Regards,

Jagan.

Not applicable
Author

Hi,

Load if(wildmatch(Country,'United States of America','China','Taiwan','Germany (Federal Republic of)', Country ='Netherlands') >0

and wildmatch(Status= 'Allowed','Granted')> 0

                    and wildmatch(Company,'ABC') >0 and

wildmatch(DFAnalysis,'Low') >0

AND  IFSCORE >= 3, 'LOW', 'NA')  as VettingStage,

ID

                    Resident Temp;

I am getting only one value for VettingStage field which is NA, and this means something is worng in this condition. Can you please check?

Thanks a lot for your reply.

Not applicable
Author

Hi,

Try this.its working fine.

test:
Load * Inline
[ Country,Status,Company,DFAnalysis,IFSCORE
United States of America,Allowed,ABC,Low,5
China,Granted,ABC,Low,8
];

load
if(
                 (wildmatch(Country,'United States of America','China','Taiwan','Germany (Federal Republic of)', 'Netherlands') >0 )
                   and wildmatch(Status, 'Allowed','Granted')> 0
                   and (Company='ABC')
                   and (DFAnalysis='Low')
                   and IFSCORE >= 3,
                  'LOW', 'NA') as test1
resident test;

Not applicable
Author

hi,

Ur condition was failing in line

1) "if(wildmatch(Country,'United States of America','China','Taiwan','Germany (Federal Republic of)', Country ='Netherlands') >0"

observe in this line u have used " Country ='Netherlands' " ,this is wrong syntax, as u have alredy mentioned Country  field as first parameter in wildmatch function

2) " wildmatch(Status= 'Allowed','Granted')> 0

                    and wildmatch(Company,'ABC') >0

"

beacuse you putted "=" sign after status inplace of ","  .

Also we dont need to put wildmatch or match when we have only one value to cample in field, so no need of using wildmatch for "Company" "FAnalysis".

Not applicable
Author

LOAD

if(

                    (

                     Country = 'United States of America' or

                     Country ='China' or

                     Country ='Taiwan' or

                     Country ='Germany (Federal Republic of)' or

                     Country ='Netherlands'

                     )

          AND

                    (

                     "Status"= 'Allowed' or "Status"='Granted'

                    )

          AND

                    (

                     Company = 'ABC'

                    )

          AND

                    (

                    DFAnalysis = 'Low'

                    )

          AND

                    (

                     IFSCORE >= 3

                    )

,'LOW','NA')

MAY be it's run

Not applicable
Author

Hi,

Load if(wildmatch(Country,'United States of America','China','Taiwan','Germany (Federal Republic of)', 'Netherlands') >0 and wildmatch(Status= 'Allowed','Granted')> 0

and( Company = 'Apple')

and  (DFAnalysis = 'Low')

AND  (IFSCORE >= 3), 'LOW', 'NA')  as VettingStage,

ID

Resident Temp;

I am using this, but its still not working. also, I tried breaking this if statement but, only the country condition in the above is working and no other condition seems to be working fine. I am not sure about the reason, can you please tell me what could be the reasons?

Thanks a lot.

Not applicable
Author

hi,

their is error in ur secound line "wildmatch(Status= 'Allowed','Granted')> 0" that you have written ,

dont write "=" sign after Status it should be "wildmatch(Status, 'Allowed','Granted')> 0".

I mentioned it above also.

Please correct this line.

Not applicable
Author

Hi, I corrected this error, but by mistake I posted it here. Sorry about that. All my conditions worked except these :

Company = 'Apple' and IFSCORE>=3 and NOT Tag LIKE '*Rejected*'

So, when I run my script with the following code it runs fine:

Load if(wildmatch(Country,'United States of America','China','Taiwan','Germany (Federal Republic of)', 'Netherlands') >0 and wildmatch(Status, 'Allowed','Granted')>0

and  (DFAnalysis = 'Low')

, 'LOW', 'NA')  as VettingStage,

ID

Resident Temp;

But, when I am adding the above 3 conditons , I only get output as NA for the Vetting stage field.

I am using the following expression.

Load if(wildmatch(Country,'United States of America','China','Taiwan','Germany (Federal Republic of)', 'Netherlands') >0 and wildmatch(Status, 'Allowed','Granted')>0

and Company = 'Apple' and IFSCORE>=3 and NOT Tag LIKE '*Rejected*'

and  (DFAnalysis = 'Low')

, 'LOW', 'NA')  as VettingStage,

ID

Resident Temp;

Tag is a field name in my data model. I tried running my script, but any of these above conditions are not working, even though I have records that satisfy these conditons.

Thank you. I would really appreciate your response.