我需要帮助在下拉列表中获取“所有报告”选项才能运行“所有报告”
我从表 A 中提取,该表有 4 个事务状态...“03”、“05”、“06”和“06”。 '07'
我已经定义了一个提取它们的数据集...
SELECT 'ALL' AS label, NULL AS value, 0 AS iordr
UNION ALL
SELECT '03' AS label, '03' AS value, 1 AS iordr
UNION ALL
SELECT '05' AS label, '05' AS value, 2 AS iordr
UNION ALL
SELECT '06' AS label, '06' AS value, 3 AS iordr
UNION ALL
SELECT '07' AS label, '07' AS value, 4 AS iordr
ORDER BY iordr
但是当我尝试定义参数时,当我从报告的下拉列表中选择全部时,它不会提取“03”、“05”、“06”和“07” - 事实上,它什么也没拉...我该如何做才能使“全部”选择在一份报告中拉出所有状态?
报告参数属性:
常规
数据类型:文本;允许空值
选择参数可见性:可见
可用值:
从以下选项之一中进行选择:
从查询中获取值
数据集(上面定义的)
值字段:值
标签字段:标签
默认值:
从以下选项之一中进行选择: 无默认值
I'm pulling from Table A which has 4 Transaction Statuses... '03', '05', '06', & '07'
I've defined a dataset which pulls them...
SELECT 'ALL' AS label, NULL AS value, 0 AS iordr
UNION ALL
SELECT '03' AS label, '03' AS value, 1 AS iordr
UNION ALL
SELECT '05' AS label, '05' AS value, 2 AS iordr
UNION ALL
SELECT '06' AS label, '06' AS value, 3 AS iordr
UNION ALL
SELECT '07' AS label, '07' AS value, 4 AS iordr
ORDER BY iordr
But when I try to define the Parameter, when I select ALL from the drop down of the report, it doesn't pull '03', '05', '06' and '07' - in fact, it pulls NOTHING... how do I make it so that the 'ALL' choice will pull ALL statuses in one report?
Report Parameter Properties:
General
Data Type: Text; Allow null Value
Select parameter visibility: Visible
Available Values:
Select from one of the following options:
Get values from a query
Dataset (the one defined above)
Value field: value
Label field: label
Default Values:
Select from one of the following options: No default value
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
从下拉列表中选择的值将为
{ NULL, '03', '05', '06', '07' }
之一。因此,您可以在报告中编写WHERE
子句,如下所示:如果您的
WHERE
子句只是WHERE SomeColumn = @UserSelectedValue
,则它将不起作用因为= NULL
无效(无论如何作为 ANSI 标准),并且它只会为您提供SomeColumn
为NULL
的结果。通过有效比较
NULL IS NULL
,您可以创建一个适用于每一行的条件,从而为您提供所有数据。The value selected from your dropdown will be one of
{ NULL, '03', '05', '06', '07' }
. So you can write yourWHERE
clause in the report like this:It won't work if your
WHERE
clause is justWHERE SomeColumn = @UserSelectedValue
because= NULL
is not valid (as ANSI-standard anyway), and it would only give you results forSomeColumn
beingNULL
.By effectively comparing
NULL IS NULL
you're creating a condition that holds for every single row, and thus gives you all the data.在 SSRS 中,多值参数以逗号分隔的字符串形式传递给 SQL。
使用 SSRS 多值参数的最简单方法是将完整的 SQL 查询嵌入到数据集中,并使用以下形式
WHERE myTable.Column IN ( @MyParameterName )
或者您可以移动过滤参数进入数据集过滤器或者您正在使用的 tablix 上的过滤器。
如果您确实需要将多值参数传递给存储过程,那么您将需要进行一些字符串解析,以将其拆分为适当的逗号。
In SSRS, multi-value parameters are passed to SQL as a comma separated string.
The easiest way to use a SSRS multi-value parameter is to have the full SQL query embedded in a dataset, and use the form
WHERE myTable.Column IN ( @MyParameterName )
Or you can move your filtering parameter into the dataset filter or maybe a filter on the tablix that you are using.
If you really need to pass the multi-value parameter in to a stored procedure, then you will need to do a little bit of string parsing to split it at the appropriate commas.