Solved

SSRS - Date Parameter - Is it possible to have a multi select date range?

Posted on 2014-01-04
9
3,047 Views
Last Modified: 2014-01-06
Hi Experts, I have a problem creating a parameter for a date range which now needs to be a changed to a multi select parameter.
I am using Report Builder 2008 R2. I am using the Filter tab in the report Builder.

I have a date field which indicates how overdue the payments are.

I need to have 4 date ranges between (today() and -30days), (-30days and -60days), (-60days and -90 days) and lastly (more than -90 days). I have this part working now but I now have to change this so that users can select a combination of the 4 date ranges. Is this possible??

If so how would I do this?
0
Comment
Question by:Papa1NZ
  • 5
  • 3
9 Comments
 
LVL 12

Expert Comment

by:Tony303
ID: 39757047
So, I think I understand what you want.

you want a drop down of the 4 values showing the values "4/1/2014 - 3/12/2013", "3/12/2013 - 2/11/2013", "2/11/2013 - 1/10/2013", "older than 1/10/2013"?

you say the user can select a combination of the 4 date ranges.
I'd day this may be hard to do.

Anyway,

I think you can go this way...

For the dataset for the parameter I think you should do this.

Select Convert(Date,Getdate()) as StartDate,  
Convert(Date,DATEADD(D,-30,GetDate())) AS EndDate,
CONVERT(VARCHAR(12),Convert(Date,Getdate())) + ' - ' + CONVERT(Varchar(12),Convert(Date,DATEADD(D,-30,GetDate()))) AS Label

UNION

Select Convert(Date,DATEADD(D,-30,GetDate())) as StartDate,  
Convert(Date,DATEADD(D,-60,GetDate())) AS EndDate,
CONVERT(VARCHAR(12),Convert(Date,DATEADD(D,-30,GetDate()))) + ' - ' + CONVERT(Varchar(12),Convert(Date,DATEADD(D,-60,GetDate()))) As Label

UNION

Select Convert(Date,DATEADD(D,-60,GetDate())) as StartDate,  
Convert(Date,DATEADD(D,-90,GetDate())) AS EndDate,
CONVERT(VARCHAR(12),Convert(Date,DATEADD(D,-60,GetDate()))) + ' - ' + CONVERT(Varchar(12),Convert(Date,DATEADD(D,-90,GetDate()))) As Label

UNION

Select Convert(Date,DATEADD(D,-90,GetDate())) as StartDate,  
'1900-01-01' AS EndDate,
CONVERT(VARCHAR(12),Convert(Date,DATEADD(D,-90,GetDate()))) + ' - ' + '1900-01-01' As Label

Order by Startdate desc

Open in new window

0
 
LVL 65

Expert Comment

by:Jim Horn
ID: 39757561
Looks like the above answer is correct as far as populating the parameter list.

SQL expert ValentinoV wrote an article on SSRS Passing multi-value parameters that I'm about to do a deep dive into.  Good luck.
0
 

Author Comment

by:Papa1NZ
ID: 39758223
Hi Tony / Jim.

Thank you for your responses. I should have mentioned this earlier but the application driver I am using to access the database does not allow me to use stored procedures and it has limited query syntax for the dataset. So I have to try and find a work around by using SSRS report features.

I would need to do this using the expression in the filter/parameter of the report builder / BIDS. Or/And use the 'Code' section. Is this possible?

What I want to do is have 4 labels.
(1) 'Overdue<30 days', (2) '-30days and -60days', (3) '-60days and -90 days',  (4)'>90 days'.

What I did previously (Note: I didn't need the Overdue<30 in the earlier version) is create a Parameter which would create the end date required for the date range. When the users selected the label with e.g. '-30days and -60days' the system date minus 60 days would be passed as a parameter.
Parameter Label Expression:
=DateAdd("d",-30,Today())
=DateAdd("d",-60,Today())
=DateAdd("d",-90,Today())

With the date filter I used end date as the passed Parameter. For the start date I used the following expression:
=IIf(Parameters!OverDueDate.Value=DateAdd("d",-60,Today()),
DateAdd("d",-90,Today()),
IIf( Parameters!OverDueDate.Value=DateAdd("d",-90,Today()),
DateAdd("d",-100000,Today()), DateAdd("d",-60,Today()) )    )

This worked fine. However it now needs to be a multi select which will not work with the way I have created this filter.

Can you tell me other ways I might be able to create a multi-select range of dates?

Many thanks
Parameter-list.PNG
2FilterTab.PNG
0
 
LVL 12

Accepted Solution

by:
Tony303 earned 500 total points
ID: 39758357
Hey Papa,

Are you able to actually add a column to the underlying query? Please say yes!!

In the past I have added a column called Age lets say and then populated each line with 0 for Current, 1 for 30Days, 2 for 60Days, 3 for 90 days and 4 for 90+.

This then makes the selection the user chooses really easy.
They want Current and 90+, you have in your filter Age in (1,4).

T
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 

Author Comment

by:Papa1NZ
ID: 39758423
Hi Tony,

Thanks I am now using 1, 2, 3, 4 instead of the dates. This works but is it possible do a multi-select version of this? My idea now is to find the Min value out of (1,2,3,4) and use that as the start date period and the Max value to use the end date for the 'between' date filter.  I am just trying to do this now but I am unsure if this will be accepted as a work around?
Do you think it is possible to get a multi-select date range? E.g. Period '0-30', and '>-90' when a user selects 1 and 4 missing 2,3?

Currently using single selection I use the following in the DataSet Filter.

Start Date
=IIf(Parameters!OverDueDate.Value=1, DateAdd("d",-30,Today()), IIf( Parameters!OverDueDate.Value=2, DateAdd("d",-60,Today()), IIf( Parameters!OverDueDate.Value=3, DateAdd("d",-90,Today()), DateAdd("d",-1,"01/01/1900"))))

End Date
=IIf(Parameters!OverDueDate.Value=1, Today(), IIf( Parameters!OverDueDate.Value=2, DateAdd("d",-30,Today()), IIf( Parameters!OverDueDate.Value=3, DateAdd("d",-60,Today()), DateAdd("d",-90,Today()))))

This works fine for single selection but how would I change this to now use multi-selection?

Many thanks
values-Parameter-Instead-Of-Date.PNG
0
 

Author Comment

by:Papa1NZ
ID: 39760857
Hi Tony,
Sorry I have just clicked about what you said above. So I should create a column in the query? Would I use Case in the select statement? Or do you mean adding the column somewhere else?
0
 

Author Comment

by:Papa1NZ
ID: 39760960
Tony just set it up. It was simple in the end like you said. I just created a calculated column and used that in my multi-selection list.
Thanks.
0
 

Author Closing Comment

by:Papa1NZ
ID: 39760963
This is a good solution. Creating a calculated field instead where you use a switch command and DateDiff and assigning the string to the appropriate ranges.
0
 
LVL 12

Expert Comment

by:Tony303
ID: 39761156
Hi Papa,

Sorry I haven't got back to you again. For some reason the pre Christmas work rush hasn't abated...

Anyway, I am pleased you are now fully on track.

Thank you for your points, I really appreciate it.

Cheers now.

T
0

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Suggested Solutions

After much searching across the internet I have found that you could not set the name of the file you were attaching to dynamic report subscriptons in Microsoft Reporting Services. I did manage to find one article showing you how your could make a s…
Hi, I have heard from my friends that it’s not possible to create Label Printing report using SSRS. I am amazed after hearing this words not possible in SSRS. I googled lot and found that it is possible to some of people know about the Report Bui…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now