Hi,
I would really appreciate help with a beast mode that I am unable to resolve even after looking into many answers on dojo. The beast mode looks like below:
CASE when
(CASE when `Cost Type` like 'Fix Price' then
(CASE when `End Date` < CURRENT_DATE-3 then `CPM`
else (`CPM`/(DATEDIFF(`End Date`,`Start Date`)+1))*(DATEDIFF(MAX(`Date`),`Start Date`)+1) end)
when `Cost Type` like 'CPC' and SUM(`Clicks`) > 0 then SUM(`Clicks`)*`CPM`
when `Cost Type` like 'CPM' then SUM((`Impressions`)/1000)*`CPM`else 0 end) = 0
then 0
else SUM(`VT`)/(CASE when `Cost Type` like 'Fix Price' then
(CASE when `End Date` < CURRENT_DATE-3 then `CPM`
else (`CPM`/(DATEDIFF(`End Date`,`Start Date`)+1))*(DATEDIFF(MAX(`Date`),`Start Date`)+1) end)
when `Cost Type` like 'CPC' and SUM(`Clicks`) > 0 then SUM(`Clicks`)*`CPM`
when `Cost Type` like 'CPM' then SUM((`Impressions`)/1000)*`CPM`
else 0 end)
end
It should:
- show division of two numbers: SUM of VT / SUM of another calculated summarized value based on multiple conditions
- to avoid error when dividing by zero, I first check that the calculated value is not 0
However what it results in instead us SUM of multiple calculations (VT / Fix price + VT / CPC + VT/CPM).
I want to display the result as a single value chart type.
What am I doing wrong here?