Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Limit the number of months to the last three months using ssrs Expand / Collapse
Author
Message
Posted Tuesday, November 12, 2013 4:01 PM
Valued Member

Valued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued Member

Group: General Forum Members
Last Login: Tuesday, February 18, 2014 5:22 PM
Points: 58, 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 ?
Post #1513653
Posted Tuesday, November 12, 2013 4:51 PM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Yesterday @ 3:25 PM
Points: 6,932, Visits: 12,665
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
Post #1513662
Posted Tuesday, November 12, 2013 5:19 PM
Mr or Mrs. 500

Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500

Group: General Forum Members
Last Login: Yesterday @ 11:06 PM
Points: 578, Visits: 3,762
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.
Post #1513665
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse