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

Announcements
Join us in Bucharest on Sept 18th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
TomBond77
Specialist
Specialist

nested IF with and in App

Hi experts

I have this IF clause:

if([CostCenter]<>'2450', -Sum(amount) / 1000, if([CostCenter]='2450' and
match(Counter, 'Music ' ,'TV'), -sum(amount) / 1000), sum(amount) / 1000)))

Syntax error says: IF takes 2-3 parameters.

But due to the help.qlik it should work?

This clause is not in the loading script. It is in the App on a measure.

Any ideas?

Thanks, Tom

 

2 Replies
TomBond77
Specialist
Specialist
Author

I found the cause of this error:

if([CostCenter]<>'2450', -Sum(amount) / 1000, if([CostCenter]='2450' and
match(Counter, 'Music ' ,'TV'), -sum(amount) / 1000), sum(amount) / 1000)))

Correct:

if([CostCenter]<>'2450', -Sum(amount) / 1000, if([CostCenter]='2450' and
match(Counter, 'Music ' ,'TV'), -sum(amount) / 1000, sum(amount) / 1000)))

Now it says, garbarge after expression:  ')'....

 

Any ideas?

Almen
Creator II
Creator II

Hello,

try this:

 

if([CostCenter]<>'2450', -Sum(amount) / 1000,
 if([CostCenter]='2450' and match(Counter, 'Music ' ,'TV')>0,
 -sum(amount) / 1000
 ),
 sum(amount) / 1000
)

 

 

 

The second if does not return an exception. In case you need it, switch the brackets:

 

if([CostCenter]<>'2450', -Sum(amount) / 1000,
 if([CostCenter]='2450' and match(Counter, 'Music ' ,'TV')>0, 
 -sum(amount) / 1000, sum(amount) / 1000
 )
)