Qlik Community

Ask a Question

Qlik Sense App Development

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

Announcements
Qlik Highlights 2020 Giveaway! Watch, reply and have a chance to win a $200 Amazon Gift Card! Watch Video
cancel
Showing results for 
Search instead for 
Did you mean: 
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
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))

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.

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))

 

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))

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