
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
If Statement with And Opperator
Hi,
I'm trying to include an AND operator in my IF statement, but I'm getting the error: ')' expected from the below bit of script. The first line works perfectly and is just an example of what I'm trying to do.
IF("Success Percentage" >= .76, 1, 0) AS '76-100',
IF("Success Percentage" =< .75 AND "Success Percentage" >= .51, 1, 0) AS '51-75'
I'd be grateful for any assistance.
- Tags:
- if(and
- ifcondition
Accepted Solutions


- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Got it
You have =< instead of <=
Please mark the appropriate replies as CORRECT / HELPFUL so our team and other members know that your question(s) has been answered to your satisfaction.
Regards,
Mike Tarallo
Qlik
Mike Tarallo
Qlik

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Qlikview was interpreting your nested if statement as 1 statement and you had two different alliases in one statement. You are better off creating the indicator in two different fields.
IF([Success Percentage] >= .76, 1, 0) AS '76-100'
IF([Success Percentage] =< .75 AND [Success Percentage] >= .51, 1, 0) AS '51-75'

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Apologies for the confusion - my script was not intended to be a nested if statement. I meant to have two different fields.
I ran what you provided:
IF([Success Percentage] >= .76, 1, 0) AS '76-100'
IF([Success Percentage] =< .75 AND [Success Percentage] >= .51, 1, 0) AS '51-75'
And, I'm experiencing the same error. Any ideas?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Try
IF(([Success Percentage] >= .76), 1, 0) AS '76-100'
IF(([Success Percentage] =< .75) AND ([Success Percentage] >= .51), 1, 0)) AS '51-75'

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
load
[Success Percentage],
IF([Success Percentage] >= .76, 1, 0) AS '76-100',
IF([Success Percentage] <= .75 AND [Success Percentage] >= .51, 1, 0) AS '51-75';
load * inline [
Success Percentage
0.32
0.6
0.7
0.8
];


- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Brenna - Nick's suggestion is correct if you are using this in the Load Script, for both QlikView and Qlik Sense. The AS keyword allows you to alias the expression as a field value and will then be part of the data model.
- but if you are using Qlik Sense you might also find these videos helpful - as they show you to define the script in reusable objects - measures and dimensions within the Master Items list.
More videos here: New to Qlik Sense Videos
Let us know how you do.
Please mark the appropriate replies as CORRECT / HELPFUL so our team and other members know that your question(s) has been answered to your satisfaction.
Regards,
Mike Tarallo
Qlik
Mike Tarallo
Qlik

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thank you all!
Though It appears that neither of Nick's suggestions will work for me. The first line with the field '76-100' works perfectly, but the second does not. Are AND operators allowed in IF in Qlik Sense?


- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Brenna,
See attached .qvf - this does work for me in my version of Qlik Sense Desktop 1.1
copy to C:\Users\<user profile>\Documents\Qlik\Sense\Apps refresh the Desktop (F5)
-----------------
Load
[Success Percentage],
IF(([Success Percentage] >= .76), 1, 0) AS '76-100',
IF(([Success Percentage] <= .75) AND ([Success Percentage] >= .51), 1, 0) AS '51-75';
load * inline [
Success Percentage
0.32
0.6
0.7
0.8
];
Is it possible your error is coming from somewhere else in the script?
Please mark the appropriate replies as CORRECT / HELPFUL so our team and other members know that your question(s) has been answered to your satisfaction.
Regards,
Mike Tarallo
Qlik
Mike Tarallo
Qlik


- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Got it
You have =< instead of <=
Please mark the appropriate replies as CORRECT / HELPFUL so our team and other members know that your question(s) has been answered to your satisfaction.
Regards,
Mike Tarallo
Qlik
Mike Tarallo
Qlik

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Huzzah! Thank you all.
