Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
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..
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)
))
)
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)
))
)
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
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)
) )
)