在我的SSRS报告中,我已经有了一个数据集A(通过运行SQL脚本),参数P1使用A中的所有记录。现在我想获得A的子集,并使用另一个参数P2来引用它。
是否有可能同时获取数据集的整体和子集,并且只运行一次脚本?
我想创建共享数据集是一种可行的方法,但数据集A仅供本地使用,不应共享。
In my SSRS report, I already have a dataset A(by running a SQL script), and parameter P1 use all the records in A. Now I want to get a subset of A, and use another parameter P2 to refer to it.
Is it possible that get the whole and the subset of the dataset at the sametime and only run the script once?
I guess creating a shared dataset is a possible way, but the dataset A is just for locally use and shouldn't be shared.
最满意答案
简短的回答
不,这是不可能的。
替代
您可以修改查询,以便返回一列以填充P1参数,并返回其他列以填充P2。 例:
select 'Foo' P1, 'Foo' P2 union all select 'Bar', 'Bar' union all select 'Foobar', null返回:
P1 P2 Foo Foo Bar Bar Foobar null使用P1列填充P1参数,使用P2填充P2参数。
注意子集列(在我的情况下为P2)的值小于P1,如果您的参数设置为允许NULL值,它将在选择列表中显示NULL选项,否则不会。
这个解决方案可能对您有用,但如果您需要数据集只运行一次我不确定,我认为SSRS将为每个参数运行查询,即使两个参数都是从一个数据集填充的。
如果这有帮助,请告诉我。
Short answer
No, it is not possible.
Alternative
You can modify your query in order to it returns one column for populate the P1 parameter and other column to populate P2. Example:
select 'Foo' P1, 'Foo' P2 union all select 'Bar', 'Bar' union all select 'Foobar', nullReturns:
P1 P2 Foo Foo Bar Bar Foobar nullUse P1 column for populate the P1 parameter and P2 for populate P2 parameter.
Note the subset column (P2 in my case) has less values than P1, if your parameter is set to allow NULL values, it will show the NULL option in select list otherwise it won't.
This solution could work for you but if you need the dataset runs only once I am unsure of that, I think SSRS will run the query for every parameter even if both parameters are being populated from one dataset.
Let me know if this helps.
更多推荐
发布评论