Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Multiple conditions under if statement in QlikView Script

I am trying to create a field/dimension based on multiple if statement.

However, I get error if I try to use multiple conditions under one if statement.

For example:-

if([Country] = 'France ',[Valid_YN]= 'Yes',[Code]= 'AA5','AA6','AA3',[Branch]<>'221,'223','224',[Amount1],'0',

if([Country] = ''France' and [Process]  = 'A','B' ,[Company] = 'X',[Amount1]+[Amount2])) as [Net_Amount]

Could any one please help me to work on the right approach towards this issue ?

Thanks !!!!

1 Solution

Accepted Solutions
Anonymous
Not applicable
Author

mot sure it thats what you want,

if([Country] = 'France ' and [Valid_YN]= 'Yes' and match([Code]='AA5','AA6','AA3')>0 and match([Branch],'221,'223','224')=0,[Amount1],'0',

if([Country] = ''France' and [Process]  .... same as above

you Need to use and/or  to separate the different conditions

View solution in original post

7 Replies
hic
Former Employee
Former Employee

1) You need to use "and" and "or" instead of comma between your conditions.

2) You need to use Match() instead of a test against several values, e.g.

      Match(

, 'AA5','AA6','AA3')

HIC

Anonymous
Not applicable
Author

mot sure it thats what you want,

if([Country] = 'France ' and [Valid_YN]= 'Yes' and match([Code]='AA5','AA6','AA3')>0 and match([Branch],'221,'223','224')=0,[Amount1],'0',

if([Country] = ''France' and [Process]  .... same as above

you Need to use and/or  to separate the different conditions

Not applicable
Author

Thanks Rudolf...It works

tcreddy1
Contributor
Contributor

Hi Greetings to all. 

Could any of you please help me why I am getting error  when use the following expression to display a number(result) in a text box with the following code: 

Req: I need to display num(SalesReps) in two branches.  

=Num(Aggr(If(<BrachName>='ABC'and‘XYZ’, Count(SalesRep))))

 

Thank you

Creddy

zototo
Contributor III
Contributor III

Hello Hic, 

I do really appreciate your help as I got totally stuck with expression and seems like the answer to this post is the closest to mine. The only difference is that I'm working in Sense. 

Basically, I need a condition in expression when at the same time both Game Supplier 'PS' and 'GF' >0. I've tried different expressions but it gives me only count if any of Game Supplier is > 0,  to use AND and OR but it always shows an error. What can be wrong? 

if([Game Supplier] = {'PS'} and [Game Supplier] = {'GF'} and TermType = {'TB'} and match(COUNT_GAMES = {"=COUNT_GAMES > '0'"})>0,count(distinct SHOP_NAME),0)

count({ $< COUNT_GAMES = {"=COUNT_GAMES > '0'"}, TermType = {'TB'}, [Game Supplier] = {'GF'}>+ <COUNT_GAMES = {"=COUNT_GAMES > '0'"}, TermType = {'TB'}, [Game Supplier] = {'PS'}>} distinct SHOP_NAME)

Count({$<COUNT_GAMES={">0"},TermType={'TB'},[Game Supplier]={'GF','PS'}>} DISTINCT SHOP_NAME)

Count({$<COUNT_GAMES-={0}>*<TermType={'TB'}>*<[Game Supplier]={'GF','PS'}>} DISTINCT SHOP_NAME)

Looking forward to your answer and thank you in advance!

BrunPierre
Master
Master

Hi @zototo  Could you share the data along with the anticipated outcomes

zototo
Contributor III
Contributor III

Thank you, but I am working in Qlik Sense and I'm getting errors. Do you have any ideas why?