So at the moment I have an SSRS report that uses lookup functions to compare different datasets to compare the current year over the base (the starting year) of 2013. Now I want to change these SQL datasets to make another report that will do a dynamic year over year. So for the first year it would give me the same results as year over year (since it would be comparing 2014 to 2013 still) and then next year it would compare 2015 to 2014 for each month. I am doing this in the SSRS SQL Query Designer. My SQL statement that shows the current year is:
SELECT PLN.ALN, TO_CHAR(PLN.FT_DTE, 'YY/MM') AS "MM-YY", COUNT(*) AS ALT,
trim(CONCAT(PLN.ALN, to_char(PLN.FT_DTE, 'YY/MM'))) AS MONTHKEY,
PERFORMANCE.STATUS
FROM PLN, PERFORMANCE
WHERE PLN.OG = PERFORMANCE.OG AND
PLN.DST = PERFORMANCE.ACT_DST AND
PLN.FT_N = PERFORMANCE.FT AND
PLN.FT_DTE = PERFORMANCE.FT_DT AND
PLN.TIL = PERFORMANCE.ACT_TIL AND (PLN.FT_DTE BETWEEN
:P_Start_Date AND :P_End_Date) AND (PLN.DST = 'FDS') AND (PERFORMANCE.STUS = 'RAR') AND
(PLN.ALN IS NOT NULL)
GROUP BY PLAN.ALN, TO_CHAR(PLN.FT_DTE, 'YY/MM'),
PERFORMANCE.STUS
ORDER BY PLN.ALN, "MM-YY"
This allows me to specify a date and it will count the number of occurrences per month of a certain field.
Now I need to write another SQL as a separate dataset that will find last years information dynamically (instead of a static dataset that just finds 2013 information like I have now for a year over base report). I assume the SQL will be similar to the one I wrote above but I'm not sure how to make it dynamic like that. Essentially for 2014 it should find the exact same information. Its when 2015 comes is when this report will be different than the other.