I have the following Beast Mode working for a comparison table (Period over Period is the name of the variable:
CASE
WHEN Period Over Period
= 'Week over Week' THEN (CASE WHEN WEEK(Date
) = WEEK(CURDATE() - INTERVAL 1 WEEK) AND YEAR(Date
) = YEAR(CURDATE() - INTERVAL 1 WEEK) AND DAYOFWEEK(Date
) <= DAYOFWEEK(CURDATE()) THEN Amount
END)
WHEN Period Over Period
= 'Month over Month' THEN (CASE WHEN MONTH(Date
) = MONTH(CURDATE() - INTERVAL 1 MONTH) AND YEAR(Date
) = YEAR(CURDATE() - INTERVAL 1 MONTH) AND DAYOFMONTH(Date
) <= DAYOFMONTH(CURDATE()) THEN Amount
END)
WHEN Period Over Period
= 'Quarter over Quarter' THEN (CASE WHEN QUARTER(Date
) = QUARTER(CURDATE() - INTERVAL 1 QUARTER) AND YEAR(Date
) = YEAR(CURDATE() - INTERVAL 1 QUARTER) AND DAYOFYEAR(Date
) <= DAYOFYEAR(CURDATE() - 91) THEN Amount
END)
WHEN Period Over Period
= 'Year over Year' THEN (CASE WHEN YEAR(Date
) = YEAR(CURDATE() - INTERVAL 1 YEAR) AND Date
< DATE_SUB(CURDATE(), INTERVAL 1 YEAR) THEN Amount
END)
END
What I want to add is 'Week over same Week Last Year', 'Month over same Month Last Year', and 'Quarter over same Quarter Last Year'. And if possible, 'Last 12 Months' to compare to the previous 12 month period (this is probably the hardest to execute in a beast mode).
Is there a way of adding the above to the beast mode? I know I could do in the ETL, just wanting to see if this is possible in beast mode.