November 12, 2013 at 4:01 pm
Hello ;
I have a dataset which kind of gives me the below output :
Year Month TotalSales TotalProducts
2013 1 23233 45
2013 2 3344 43
2013 3 232 11
2013 4 2232 23
I am trying to represent the above dataset in a table and a bar graph.
Is there a way I can limit the months to the last three months.
I am using the current month as a parameter.
So suppose , I choose month 4 as a parameter , i would like to see the results only for the months 4,3 & 2 in the bar chart I am using ?
Is there a way I can do it ?
November 12, 2013 at 4:51 pm
It depends on the query being used to get the raw data.
It might be sufficient to add a "TOP 3 ... ORDER BY Year DESC, Month DESC" to the underlying query, assuming the filter condition to use the parameter is already in place. Hard to tell...
However, dealing with a month number alone might lead to unexpected results.
Example: What would you expect for month number = 1? And how does your current query is designed to apply the filter for the expected output?
November 12, 2013 at 5:19 pm
Kind of depends where you do the limiting... if you do it in the stored procedure, use something like
SELECT...
FROM ...
[SomeDate] >= DATEDIFF(m,-3,GETDATE())
Trying to subtract from a MONTH() value won't work.
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply