我需要帮助在下拉列表中获取“所有报告”选项才能运行“所有报告”

发布于 2024-12-11 08:55:41 字数 700 浏览 0 评论 0原文

我从表 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

颜漓半夏 2024-12-18 08:55:41

从下拉列表中选择的值将为 { NULL, '03', '05', '06', '07' } 之一。因此,您可以在报告中编写 WHERE 子句,如下所示:

SELECT ...
FROM ...
WHERE SomeColumn = @UserSelectedValue
  OR @UserSelectedValue IS NULL
;

如果您的 WHERE 子句只是 WHERE SomeColumn = @UserSelectedValue,则它将不起作用因为 = NULL 无效(无论如何作为 ANSI 标准),并且它只会为您提供 SomeColumnNULL 的结果。

通过有效比较NULL IS NULL,您可以创建一个适用于每一行的条件,从而为您提供所有数据。

The value selected from your dropdown will be one of { NULL, '03', '05', '06', '07' }. So you can write your WHERE clause in the report like this:

SELECT ...
FROM ...
WHERE SomeColumn = @UserSelectedValue
  OR @UserSelectedValue IS NULL
;

It won't work if your WHERE clause is just WHERE SomeColumn = @UserSelectedValue because = NULL is not valid (as ANSI-standard anyway), and it would only give you results for SomeColumn being NULL.

By effectively comparing NULL IS NULL you're creating a condition that holds for every single row, and thus gives you all the data.

熊抱啵儿 2024-12-18 08:55:41

在 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文