简体   繁体   中英

SSRS Set parameter value based on another parameter

I know there are a handful of questions on this already, but I feel mine is a bit different.

I've built a report that is based on a date range that the user can specify using two date parameters (DateFrom, DateTo). However, I want a dropdown available that offers predefined date ranges, for example "Last 30 Days", "Last 60 Days", "Last 90 Days", "Last Month".

I've already created a dataset that generates these rows, example row would be: Label = "Last30Days", DateFrom = 2016-08-15, DateTo = 2016-09-13

Basically, I want the usage flow as follows: User loads the report, the Predefined date range parameter defaults to the Label "Manual" Value NULL. And the two date fields are empty. The user has the option to specify their own date range to whatever they want, or they can use the drop down and choose a pre-defined date range, which when selected, it populates the date parameters.

Is this easy to accomplish? I've used cascaded parameters before, but not really like this. I'm thinking more as I type this, and am wondering if I could just use some sort of expression....like, when an option in the drop down is selected, set the parameters to these values...?

EDIT: So I was able to sort of get it working. I added available values (label/value match) to the preset dropdown for "Last [30|60|90] days", "Last month" and "manual". I set the default to "Manual". I added a parameter to the preset dates dataset and pointed it to the "PresetDates" parameter. Then I set the two date parameters to use the dataset for their default values. Now when you use the drop down, it populates the two date parameters just like I want...but if you try and select a different one once they've been populated, they don't change...

Unfortunately, this won't work the way it should because of a BUG "feature" in SSRS.

Microsoft has CLOSED this BUG feature as We Hate Our Customers it Works As Designed (even though it's stupid).

https://connect.microsoft.com/SQLServer/feedback/details/268032/default-does-not-get-refreshed-for-cascading-parameters

Here's a possible answer but I don't think it would work in your case:

http://www.bp-msbi.com/2011/04/ssrs-cascading-parameters-refresh-solved/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM