November 23, 2012 at 4:23 am
Hi all
SQL 2008 R2 Report Builder
I'll keep this simple.
Imagine I have a dataset that relates to sales.
The data set at row level has a year and month.
In the report I group by year and month.
At the year level I have an expression which shows the average sales per month for the year. An expression which sums up total sales for the year divided by distinct count of amount of months there are the in current dataset SUM(sales)/DISTINCT COUNT of Months.
This works fine.
I've now been asked at year level for an average of the last 6 months. So if we had say 11 months details at month level Jan - Nov then at Year level there would be an average of Jan - Jun sales.
Any idea on how to do this? The requesters come from Excel and they say it is easy lol, select Jan - Jun date range and choose AVG in the sum area.
Thanks,
derrysql
November 23, 2012 at 6:04 am
Could you please provide some sample data (Using TSQL) and the expected results.
That way we'll be able to help you out better and quicker.
November 23, 2012 at 6:57 am
I would probably do this with a little more work in the dataset. First start by adding some quarter definitions to your data. Then I would use a SUM OVER() to do the heavy lifting in the dataset and then simply let the report show the data.
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply