SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Limit the number of months to the last three months using ssrs


Limit the number of months to the last three months using ssrs

Author
Message
SqlServerNinja
SqlServerNinja
SSC-Enthusiastic
SSC-Enthusiastic (162 reputation)SSC-Enthusiastic (162 reputation)SSC-Enthusiastic (162 reputation)SSC-Enthusiastic (162 reputation)SSC-Enthusiastic (162 reputation)SSC-Enthusiastic (162 reputation)SSC-Enthusiastic (162 reputation)SSC-Enthusiastic (162 reputation)

Group: General Forum Members
Points: 162 Visits: 197
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 ?
LutzM
LutzM
SSC-Insane
SSC-Insane (23K reputation)SSC-Insane (23K reputation)SSC-Insane (23K reputation)SSC-Insane (23K reputation)SSC-Insane (23K reputation)SSC-Insane (23K reputation)SSC-Insane (23K reputation)SSC-Insane (23K reputation)

Group: General Forum Members
Points: 23571 Visits: 13559
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?



Lutz
A pessimist is an optimist with experience.

How to get fast answers to your question
How to post performance related questions
Links for Tally Table , Cross Tabs and Dynamic Cross Tabs , Delimited Split Function
pietlinden
pietlinden
SSChampion
SSChampion (14K reputation)SSChampion (14K reputation)SSChampion (14K reputation)SSChampion (14K reputation)SSChampion (14K reputation)SSChampion (14K reputation)SSChampion (14K reputation)SSChampion (14K reputation)

Group: General Forum Members
Points: 14010 Visits: 14127
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.
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search