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

Announcements
Want to see what's currently in public preview? We've pulled it all together in one place. Check it out here
cancel
Showing results for 
Search instead for 
Did you mean: 
ziabobaz
Creator III
Creator III

How to check for brackets in multiple if in script?

Hello,

 

I have a weird question but I spent over an hour correcting the script without luck so I would better ask than not to..

How do you usually check if brackets are put correctly when multiple IF are used?

 

if(source='ymoffer',

revenue_lnd*0.2,

if(source='google',

if(year(date)<2019,num(ad_cost)*1.18,num(ad_cost)*1.20),

if(WildMatch(source,'facebook','instagram')>0,

if(year(date)<2019,num(ad_cost),
if('31.12.2018'<date<='30.04.2019',num(ad_cost)*1.20,
if(date>'30.04.2019',num(ad_cost)*1.30)))

,ad_cost)

)

) as ad_cost,

The debugger says 'missing bracket ')' '

But I can't figure out where.

What I am trying to do is to apply coefficient to the Measure (ad_cost) based on value of Source and Date

For example if it is Google, than:

ad_cost=1.18*ad_cost (if date is before 01.01.2019)

ad_cost=1.20*ad_cost (if date is after 01.01.2019)

and so on..

Screenshot_1.jpg

1 Solution

Accepted Solutions
neelamsaroha157
Specialist II
Specialist II

Try this- 

if(source='ymoffer', revenue_lnd*0.2,
if(source='google',
if(year(date)<2019,num(ad_cost)*1.18,num(ad_cost)*1.20,
if(WildMatch(source,'facebook','instagram')>0,
if(year(date)<2019,num(ad_cost),
if('31.12.2018'<date<='30.04.2019',num(ad_cost)*1.20,
if(date>'30.04.2019',num(ad_cost)*1.30)))

,ad_cost)

))

)

View solution in original post

3 Replies
neelamsaroha157
Specialist II
Specialist II

Try this- 

if(source='ymoffer', revenue_lnd*0.2,
if(source='google',
if(year(date)<2019,num(ad_cost)*1.18,num(ad_cost)*1.20,
if(WildMatch(source,'facebook','instagram')>0,
if(year(date)<2019,num(ad_cost),
if('31.12.2018'<date<='30.04.2019',num(ad_cost)*1.20,
if(date>'30.04.2019',num(ad_cost)*1.30)))

,ad_cost)

))

)

marcus_sommer
MVP
MVP

It's difficult to say if all needed brackets are there and on the right place but at least this statement ins't valid:

... '31.12.2018'<date<='30.04.2019' ...

It should rather look like:

date > '31.12.2018' and date <='30.04.2019'

- Marcus

 

ziabobaz
Creator III
Creator III
Author

It worked with a small correction, thank you!

if(source='ymoffer', revenue_lnd*0.2,
if(source='google',
if(year(date)<2019,num(ad_cost)*1.18,num(ad_cost)*1.20 ),
if(WildMatch(source,'facebook','instagram')>0,
if(year(date)<2019,num(ad_cost),
if('31.12.2018'<date<='30.04.2019',num(ad_cost)*1.20,
if(date>'30.04.2019',num(ad_cost)*1.30)))

,ad_cost)

)  )

)