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

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Error on writing if condition to filter multiple fields using "and" operator in script

Example:

if(country='A'  and state='B' and city='C' , sum(sales)/ count(city='C'), sum(sales))

Thanks in advance.

1 Solution

Accepted Solutions
sunny_talwar

Not sure what all dimensions you have, but you at least need country, state and city because they are not aggregated

if(country='A'  and state='B' and city='C' , sum(sales)/ count(city='C'), sum(sales)) as A sales

resident table

group by Country, state, city;

View solution in original post

6 Replies
Chanty4u
MVP
MVP

its working for me

if.PNG

sunny_talwar

Are you using this in the script? I don't see anything wrong with the if statement, but if you are using this in the script, you might need a group by statement in your table load. May be provide more information to help you better

Anonymous
Not applicable
Author

yes i am using this in the script , tried using group by too. correct me if i am wrong in writing the statement.

Example:


if(country='A'  and state='B' and city='C' , sum(sales)/ count(city='C'), sum(sales)) as A sales

resident table

group by Country;

Anonymous
Not applicable
Author

yeah its working for me too in the front end but not in the script.

sunny_talwar

Not sure what all dimensions you have, but you at least need country, state and city because they are not aggregated

if(country='A'  and state='B' and city='C' , sum(sales)/ count(city='C'), sum(sales)) as A sales

resident table

group by Country, state, city;

Anonymous
Not applicable
Author

Thanks a lot sunny, its working now with group by Country, state, city.