简体   繁体   English

SSRS根据另一个参数设置参数值

[英]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). 我建立了一个基于日期范围的报告,用户可以使用两个日期参数(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". 但是,我希望有一个提供预定义日期范围的下拉菜单,例如“过去30天”,“过去60天”,“过去90天”,“过去月”。

I've already created a dataset that generates these rows, example row would be: Label = "Last30Days", DateFrom = 2016-08-15, DateTo = 2016-09-13 我已经创建了一个生成这些行的数据集,示例行将为: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. 基本上,我希望使用流程如下:用户加载报表,“预定义日期范围”参数默认为“手动”值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". 我将“过去[30 | 60 | 90]天”,“过去一个月”和“手动”的可用值(标签/值匹配)添加到预设下拉列表中。 I set the default to "Manual". 我将默认设置为“手动”。 I added a parameter to the preset dates dataset and pointed it to the "PresetDates" parameter. 我向预设日期数据集添加了一个参数,并将其指向“ PresetDates”参数。 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. 不幸的是,由于SSRS中存在 BUG “功能”,因此无法正常工作。

Microsoft has CLOSED this BUG feature as We Hate Our Customers it Works As Designed (even though it's stupid). 我们讨厌客户 按设计工作时 (即使它很愚蠢),Microsoft已关闭 BUG 功能。

https://connect.microsoft.com/SQLServer/feedback/details/268032/default-does-not-get-refreshed-for-cascading-parameters 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/ http://www.bp-msbi.com/2011/04/ssrs-cascading-parameters-refresh-solved/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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