Display dates within date ranges as groups
Hi, I'm pretty new to SSRS. I have events that run over x number of days - fields are start date, end date and number of days. I need to run a report that displays the events that are running every day, so, if the event is from June 1st to June 5th then
it needs to group and display under each day/date. What would be the best way to do this?
Using SQL Server 2008 R2
Thanks.
May 31st, 2011 9:59am
One thing you could try is to create a "Calendar Table" to join against. Then you can group by each individual date within your range and by event name.
Free Windows Admin Tool Kit Click here and download it now
May 31st, 2011 10:15am
In addition to what Tom mentioned, what you can do is to create a temporary transaction table with dates and the relevant fields. In a while loop, insert the values into this table based on the start date and end date (you can also use the number of days
to drive the loop or count the dates). So basically you will have a "de-normalized table" with the required data split across individual dates.
From the report, group by this start date and it should list all the events based on the dates. This is the immediate solution I can think of now.
Good luck.
For Eg: Say your table looks like this
Start Date End Date Num_Days EventDesc
1/1/2011 1/3/2011 3 Event 1
1/2/2011 1/4/2011 3 Event 2
After the above process the temporary table will look like this
Date EventDesc
1/1/2011 Event 1
1/2/2011 Event 1
1/3/2011 Event 1
1/2/2011 Event 2
1/3/2011 Event 2
1/4/2011 Event 2
When you group the above based on Date, the report will look like this
1/1/2011 Event 1
1/2/2011 Event 1
Event 2
1/3/2011 Event 1
Event 2
and so on.
May 31st, 2011 11:40am