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

Basic If statement query

Hi everyone,

This will be a very easy one.

I have an expression in my load script and I am doing an if expression   

if((PG = 'CAC' and PG = 'Sa'), 'Y', 'N') as PG_FLAG

I keep getting only N when I do a reload and I know that I should be getting Y.

What's wrong with my script.

Thanks

1 Solution

Accepted Solutions
Not applicable
Author

Your set analysis expression is an OR where you are saying PG = 'CAC' or 'SA'.

Logically the value in PG can only be one value or another hence when you use AND the condition can never be true.

Regards,

Gordon

View solution in original post

6 Replies
kaushiknsolanki
Partner Ambassador/MVP
Partner Ambassador/MVP

Hi,

   Instead of And use Or. like

   if((PG = 'CAC' or PG = 'Sa'), 'Y', 'N')

Regards,

Kaushik Solanki

Please remember to hit the 'Like' button and for helpful answers and resolutions, click on the 'Accept As Solution' button. Cheers!
Miguel_Angel_Baeyens

Hi,

Note that QlikView is case sensitive for both field names and values, so the field should be called PG and the possible values in the conditional "CAC" (all uppercase) and "Sa" (mixed).

Besides, one field (PG) cannot have two different values in the same record, so you will have to change it to OR instead of AND, or do something different.

Is that correct?

Miguel Angel Baeyens

BI Consultant

Comex Grupo Ibérica

Not applicable
Author

Hi guys,

Thanks for your quick reply.

My field PG has values of Sa, CAC, Ln and so on.

I have a chart with set analysis PG ={'CAC', 'Sa'}

I am just trying to remove the set analysis bit and put it in the script instead to improve performance

Using "OR" will mean it will be Y for either choice. I want it to only be Y for both choices.

I hope I have been clear enough.

Thanks for your anticipated help

kaushiknsolanki
Partner Ambassador/MVP
Partner Ambassador/MVP

Hi,

    Yes you are right or means either choice.

    So according to the statement it will only assign Y when your field value is CAC or Sa.

 

    If there is any value other than this, it will assign N.

Regards,

Kaushik Solanki

Please remember to hit the 'Like' button and for helpful answers and resolutions, click on the 'Accept As Solution' button. Cheers!
Not applicable
Author

Your set analysis expression is an OR where you are saying PG = 'CAC' or 'SA'.

Logically the value in PG can only be one value or another hence when you use AND the condition can never be true.

Regards,

Gordon

Not applicable
Author

Thank you all for your helpful responses