Wednesday, March 7, 2012

Dynamic Dates in Columns on Matrix Report?

I need to display 12 months dynamically in columns of a matrix report, starting with the current MMM, yy - 3 in the first column, current MMM, yy and incrementing by 1 month in columns 2-12.

For example a report that would run on today's MM, yy (5/2007) would look something like this:

MAR-07, APR-07, MAY-07, JUN-07, JUL-07, AUG-07, AUG-07, SEP-07, OCT-07, NOV-07, DEC-07, JAN-08, FEB-08

(Col 1 - Col 12 separated by commas)

How do I do this in a matrix report column?

1- Filter your datasource to return only those rows that meet the date criteria you describe

If SQL Server...

Code Snippet

Select Item, SalesDate, Sales from YourTable Where SalesDate >= DateAdd(dd, -3, GetDate()) AND SalesDate <= DateAdd(dd, 9, GetDate())

For example:

Item Date Sales

Bicycle Mar-07 $5000

Bicycle Apr-07 $4500

etc...

Then set your date column as the Column Group in the matrix report

Then select that column header in SSRS Layout view, and change the format property to the MMM-yy

(If the granularity of the dates in your source data is not month, if it's by day instead for instance, then you'll need to aggregate that data in your query with the appropriate Group By calls)

Hope this helps,

Geof

No comments:

Post a Comment