Qlik Community

Qlik Sense App Development

Discussion board where members can learn more about Qlik Sense App Development and Usage.

Announcements
BI & Data Trends 2021. Discover the top 10 trends emerging in today. Join us on Dec. 8th REGISTER
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Specialist
Specialist

Nested IF Statement with multiple conditions

I am attempting to create a nested if statement with several conditions. Below is how I have the expression formatted currently, however I am getting an error or 'IF takes 2-3 parameters,' which I believed I had

=if(mtrc_videoviews < 300 and brandID = 1, mtrc_impressions * 0.00936, mtrc_impressions * 0.00806, if(mtrc_videoviews < 300 and brandID = 2, mtrc_impressions * 0.00996, mtrc_impressions * 0.00762))

How can I correct

1 Solution

Accepted Solutions
Highlighted
Partner
Partner

You cannot write two else part in if statement. so structure your if something like below

if(mtrc_videoviews < 300 and brandID = 1, mtrc_impressions * 0.00936, 

if(<condition> , mtrc_impressions * 0.00806,

 if(mtrc_videoviews < 300 and brandID = 2,

mtrc_impressions * 0.00996, mtrc_impressions * 0.00762)))

View solution in original post

5 Replies
Partner
Partner

You need to write if condition for highlighted part.

if(mtrc_videoviews < 300 and brandID = 1,
mtrc_impressions * 0.00936, mtrc_impressions * 0.00806,
if(mtrc_videoviews < 300 and brandID = 2, mtrc_impressions * 0.00996, mtrc_impressions * 0.00762))

Highlighted
Creator
Creator

Is this what you are expecting?

=if(mtrc_videoviews < 300 and brandID = 1, mtrc_impressions * 0.00936,
if(mtrc_videoviews < 300 and brandID = 2, mtrc_impressions * 0.00996,
if(mtrc_videoviews >= 300 and brandID = 1, mtrc_impressions * 0.00806,
if(mtrc_videoviews >= 300 and brandID = 2, mtrc_impressions * 0.00762))))

So BrandID = 1 has two logic's based on video views similarly for BrandID = 2.

Highlighted
Partner
Partner

Hi Dear Evansabres

The highlighted part on Kush_qlik post is the wrong part of your script, you can try with the following sentence

 

=if(mtrc_videoviews < 300 and brandID = 1,
mtrc_impressions * 0.00936,
if(mtrc_videoviews < 300 and brandID = 2,
mtrc_impressions * 0.00996,
mtrc_impressions * 0.00762))

 

Highlighted
Specialist
Specialist

The format of this expression works, however I need to incorporate the highlighted portion of what I have below:

=if(mtrc_videoviews < 300 and brandID = 1, mtrc_impressions * 0.00936, mtrc_impressions * 0.00806, if(mtrc_videoviews < 300 and brandID = 2, mtrc_impressions * 0.00996, mtrc_impressions * 0.00762))

Highlighted
Partner
Partner

You cannot write two else part in if statement. so structure your if something like below

if(mtrc_videoviews < 300 and brandID = 1, mtrc_impressions * 0.00936, 

if(<condition> , mtrc_impressions * 0.00806,

 if(mtrc_videoviews < 300 and brandID = 2,

mtrc_impressions * 0.00996, mtrc_impressions * 0.00762)))

View solution in original post