SSRS 2008 Report Date Parameters
I've been asked to create report that will allow the user to view 1) All records in a dataset. 2) or only those records in dataset that are within a selected date range. (The date range I'm being asked to query against also contains null values and I need for those to appear when I view all records. Is there any way to do this in a report?
February 14th, 2011 2:49pm

Sure. Just include logic in your dataset query to only apply certain parameter logic based on the value of another parameter. For example, let's say that you have three parameters: UseDateRange, DateFrom and DateTo. UseDateRange is a string that can be "Yes" or "No" and the others are date types set to default values. The WHERE clause of a T-SQL query might look something like this: SELECT....FROM.... WHERE (@UseDateRange = 'No' OR (SomeDateField BETWEEN @DateFrom AND @DateTo))Paul Turley, MVP [Hitachi Consulting] SQLServerBIBlog.com *Please vote if helpful*
Free Windows Admin Tool Kit Click here and download it now
February 14th, 2011 3:16pm

Thanks for help with the query... How do I allow the user to decide which view they wish to see in the report? I've created a parameter that allows the user to view all records or select date range. And, I have the date range parameters available. To get report to pull at all, my work around was to assign a date to the null value in the past in the query (IsNull(field,somedate) and then I default the search parameter to one day before that date in the report when they select "View All". However, it just doesn't look clean and I'd rather do it another way. I'd really rather they be able to Select View All, and not be required to fill in a date range in the report. And, if they choose "Select Date Range" the date parameters become available and required. I hope that made sense. Samyra Chrisp
February 14th, 2011 4:02pm

Hi Samyra, You are right. The root cause of this issue is that we cannot enable/disable the range parameters based on the “View All” parameter dynamically. I also tried to set Allow null value on the FromDate and ToDate parameters. However, this also requires users to check/uncheck the NULL option after the parameter manually. Since it is a product limitation which needs to be improved, it is my pleasure to help you reflect it to the proper department. You can also submit your suggestion at https://connect.microsoft.com/SQLServer/. Your feedback is valuable for us to improve our product, and we appreciate your understanding. Thanks, Tony ChainTony Chain [MSFT] MSDN Community Support | Feedback to us Get or Request Code Sample from Microsoft Please remember to mark the replies as answers if they help and unmark them if they provide no help.
Free Windows Admin Tool Kit Click here and download it now
February 17th, 2011 3:17am

One another way to do thus is , put this logic inside a procedure and you can check the value passed in the parameter like below if @ViewAllvalues = 0 SELECT * FROM TBL WHERE DATE BETWEEN @Fromdate AND @Todate else SELECT * FROM TBL In this way you can validate if fromdate passed is less than todate also inside the proc and do neccesary actions.
February 17th, 2011 3:46am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics