Quantcast
Channel: Transact-SQL forum
Viewing all articles
Browse latest Browse all 23857

Inject Dummy Months by Group

$
0
0

Hi I am updating a report in SSRS where I am usinga Bar Chart which shows the last 12 months. However because I am using a grouping feature, each graph will only show data that is present - so if a group only had values in October, November and December the bar char only shows that and not the last 12 months.

I figure that I need to look at the underlying code to try and generate dummy months.

There is already a part of the code that injects dummy months but I need it to injects the dummy months by Insurance group

It feels like I would need to do some over partion work but I am not sure.

Here is the part of the code that injects Dummy Months

			---------------------------------------------------------------------------------------------------
			-- Inject dummy months into output so that the graphs will show months that have no data
			---------------------------------------------------------------------------------------------------
SELECT		@Count		= 0
			,@Counter	= 12

WHILE		@Count < @Counter
BEGIN
			SELECT		@Temp_Date = DATEADD(Month,(@Count)*-1,@Last_Day_Of_Last_Month)

			INSERT INTO @Output
						([Banding]
						,[Costs Settled ALL Year]
						,[Costs Settled ALL Month No]
						,[Costs Settled ALL Month Name]
						,[Costs Settled ALL Last Twelve Months Flag]
						,[Damages Settled ALL Year]
						,[Damages Settled ALL Month No]
						,[Damages Settled ALL Month Name]
						,[Damages Settled ALL Last Twelve Months Flag]
						,[File Received Year]
						,[File Received Month No]
						,[File Received Month Name]
						,[Received Last Twelve Months Flag]
						,[Last Month])

			VALUES		('Ignore'
						,DATEPART(Year,@Temp_Date)
						,DATEPART(Month,@Temp_Date)
						,SUBSTRING(DATENAME(Month,@Temp_Date),1,3)
						,1
						,DATEPART(Year,@Temp_Date)
						,DATEPART(Month,@Temp_Date)
						,SUBSTRING(DATENAME(Month,@Temp_Date),1,3)
						,1
						,DATEPART(Year,@Temp_Date)
						,DATEPART(Month,@Temp_Date)
						,SUBSTRING(DATENAME(Month,@Temp_Date),1,3)
						,1
						,@Last_Month)

			SELECT		@Count = @Count + 1
END



Viewing all articles
Browse latest Browse all 23857

Trending Articles



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