Quantcast
Channel: SQL Server Reporting Services, Power View forum
Viewing all articles
Browse latest Browse all 10045

Previous Year Expression in SSRS

$
0
0

I have 3 reports on one page, each report is the same but look at current year report 1 2010, report 2 2009 and report 3 2008

Report 1 looks at dataset1

Report 2 looks at dataset 2

Report 3 looks at dataset 3

Now the way I have done this at the moment is using a filter on each dataset

Expression = [Calendar_Year]

Operator '='

Value 2010

Basically I have hard coded these, which is ok for this current year but come next year the report will be out be a  year. I need to create an expression that does this dynamically. I was hoping to right something in each filter like below ( i know the syntax is incorrect)

=Year(getdate()yyyy) ------returns 2010

=Year(getdate()yyyy)-1 ------returns 2009

=Year(getdate()yyyy)-2  -----returns 2008

Hope you understand what I mean. I can do the following in SQL Server, if you run the below in SQL Server it will show the dates. I basically want an expression equivalent for an SSRS Expression

SELECT  (YEAR(getdate()))AS Year,
 (YEAR(getdate())-1)AS Year_1,
 (YEAR(getdate())-2)AS Year_2,
 (YEAR(getdate())-3)AS Year_3,
 (YEAR(getdate())-4)AS Year_4,
 (YEAR(getdate())-5)AS Year_5

Thanks

Greg

 

 


Viewing all articles
Browse latest Browse all 10045

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>