Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

Announcements

Breathe easy -- you now have more time to plan your next steps with Qlik!
QlikView 11.2 Extended Support is now valid through December 31, 2020. Click here for more information.

saurabh_pandit
Not applicable

If Condition for Multiple Or values in scripting

Hi all,

I face the following problem.

I get error for following:

SAP System:

//    if([Billing Type]=('F2' or 'ZDOM' or'ZTRD' or'ZTRM' or'ZDEP' or 'ZEOU' or 'ZDEX' or 'ZSEZ' or'ZCON' or 'ZJBW'or 'JOB' or 'ZDR' or'ZPWR' or 'ZSTM'),Domestic,

//    if([Billing Type]=('ZEXP' or 'ZSEA' or 'ZQT'),Exports)) as Type,

Can someone let me know the syntax for writing OR inside If statement.

Thanks,

Saurabh.

1 Solution

Accepted Solutions
nagaiank
Not applicable

Re: If Condition for Multiple Or values in scripting

Try the following:

If(Match([Billing Type],'ZEXP','ZSEA','ZQT')> 0,'Export',

If(Match([Billing Type],'F2','ZDOM','ZTRD','ZTRM','ZDEP','ZEOU','ZDEX','ZSES','ZCON','ZJBW','JOB','ZDR','ZPWR','

ZSTM')>0,'Domestic','Unknown'))

6 Replies
khadeer_sparks
Not applicable

Re: If Condition for Multiple Or values in scripting

if([Billing Type]='F2' or [Billing Type]='ZDOM' or [Billing Type]='ZTRD' or [Billing Type]='ZTRM' or [Billing Type]='ZDEP' or [Billing Type]='ZEOU' or [Billing Type]='ZDEX' or [Billing Type]='ZSEZ' or [Billing Type]='ZCON' or [Billing Type]='ZJBW' or [Billing Type]='JOB' or [Billing Type]='ZDR' or [Billing Type]='ZPWR' or [Billing Type]='ZSTM','Domestic',if([Billing Type]='ZEXP' or [Billing Type]='ZSEA' or [Billing Type]='ZQT', 'Exports'))

Do max calculation parts in Edit script.

jonbrough
Not applicable

Re: If Condition for Multiple Or values in scripting

You can use a match statement for multiple expected values of the same field.

if(match([Billing Type],'F2','ZDOM','ZTRD','ZTRM','ZDEP','ZEOU','ZDEX','ZSEZ','ZCON','ZJBW','JOB','ZDR','ZPWR','ZSTM',Domestic,

if(match([Billing Type],'ZEXP','ZSEA','ZQT'),Exports)) as Type

the above assumes you wanted to have a nested if statement and that Domestic and Exports are field names. If instead you want to have the words Domestic or Exports, encose in single quotes.

Jonathan

jagannalla
Not applicable

Re: If Condition for Multiple Or values in scripting

Hello,

Try this

if([Billing Type]= 'F2' or  [Billing Type]='ZDOM' or [Billing Type] ='ZTRD' or [Billing Type] = 'ZTRM' or [Billing Type] ='ZDEP' or [Billing Type] = 'ZEOU' or [Billing Type] = 'ZDEX' or [Billing Type] = 'ZSEZ' or [Billing Type] ='ZCON' or [Billing Type] = 'ZJBW'or [Billing Type] ='JOB' or [Billing Type] = 'ZDR' or [Billing Type] = 'ZPWR' or [Billing Type] ='ZSTM',Domestic) as Colname,

  if([Billing Type]='ZEXP' or [Billing Type]= 'ZSEA' or [Billing Type]= 'ZQT',Exports) as Type,

Cheers!!

Jagan

saurabh_pandit
Not applicable

Re: If Condition for Multiple Or values in scripting

Thanks.

They are Words so I will enclose in single quotes.

nagaiank
Not applicable

Re: If Condition for Multiple Or values in scripting

Try the following:

If(Match([Billing Type],'ZEXP','ZSEA','ZQT')> 0,'Export',

If(Match([Billing Type],'F2','ZDOM','ZTRD','ZTRM','ZDEP','ZEOU','ZDEX','ZSES','ZCON','ZJBW','JOB','ZDR','ZPWR','

ZSTM')>0,'Domestic','Unknown'))

saurabh_pandit
Not applicable

Re: If Condition for Multiple Or values in scripting

Thanks guys for all the replies.

Thanks for the multiple OR but what I was looking for is that match function.

Thanks jonbroughavone