I see in the grid filter you can do current year. Is there a way to do a constant for last year? I wanted to make it so we don’t have to change the filter every year, and employees don’t have to filter through a tracker. I don’t want to put it on the BAQ. I have a tab for current year, and a tab for prior year pulling from the same BAQ.
Here is how I have done something similar:
- Create a calculated field in the BAQ that is simply a flag… possible answers are “ThisYear”, “LastYear”, and “BeforeLastYear”. This calculation can be done very easily using the BAQ.
- on the Dashboard, you can HIDE this field, but using the TABS, you can still filter the data into three different tabs.
I was just looking this up myself before realizing I already had it in my notes.
You can use table criteria to look at the current year, previous year, next year or whichever you would like.
First day of current year
DATEADD(yy, DATEDIFF(yy, 0, GETDATE()), 0)
Last day of current year
DATEADD (dd, -1, DATEADD(yy, DATEDIFF(yy, 0, GETDATE()) +1, 0))
First day of previous year
DATEADD(yy, DATEDIFF(yy, 0, GETDATE()) -1, 0)
Last day of previous year
DATEADD (dd, -1, DATEADD(yy, DATEDIFF(yy, 0, GETDATE()) +0, 0))
First day of next year
DATEADD(yy, DATEDIFF(yy, 0, GETDATE()) +1, 0)
Last day of next year
DATEADD (dd, -1, DATEADD(yy, DATEDIFF(yy, 0, GETDATE()) +2, 0))
Here it is in c# if that helps. Todays Date minus 1 year.
DateTime.Now.AddYears(-1)
