简体   繁体   English

SSRS 报告不会遵循参数规则

[英]SSRS report won't follow parameter rules

Having a bit of trouble here, and I'm sure I have to be overlooking something.这里有点麻烦,我确定我必须忽略一些东西。

1st query:第一个查询:

    SELECT Column1, Column2, Column3 
    FROM Table1

2nd query (Will be used to create a drop-down parameter):第二个查询(将用于创建下拉参数):

    SELECT DISTINCT 
    Column1
    FROM Table1
    ORDER BY Column1

After putting this into SSRS, and creating a drop down parameter for the contents of Column1, I select the desired value and click View.将其放入 SSRS 并为 Column1 的内容创建下拉参数后,我选择所需的值并单击“查看”。 However, instead of returning the specified value, it returns all values in Column1.但是,它不会返回指定的值,而是返回 Column1 中的所有值。 I don't really want that.我真的不想那样。

What might I be missing?我可能缺少什么?

You haven't used the parameter to filter your results.您尚未使用该参数来过滤您的结果。

There are two ways to do this - either use the parameter in your query and link it to your parameter on the Parameters tab of the Dataset .有两种方法可以执行此操作 - 使用查询中的参数并将其链接到数据集的“参数”选项卡上的参数

You would add a where clause to your 1st Query to filter the results.您可以在第一个查询中添加一个 where 子句来过滤结果。 I will ass u me that you're using a multi-value parameter.屁股ü,您使用的是多值参数。

SELECT Column1, Column2, Column3 
FROM Table1 
WHERE Column1 IN (@COLUMNS) 

在此处输入图片说明

Or you could use the FILTER tab of the Dataset.或者您可以使用数据集的过滤器选项卡。

在此处输入图片说明

It's usually easier to do it in the FILTER tab but the report will usually run faster when using the WHERE clause.FILTER选项卡中执行此操作通常更容易,但使用WHERE子句时报告通常会运行得更快。 Filtering through the FILTER tab requires the query to bring back all results to the Report Server and then filter the results while using the WHERE clause lets SQL Server do the work of filtering and only returns the records needed.通过FILTER选项卡进行过滤需要查询将所有结果带回报表服务器,然后过滤结果,同时使用WHERE子句让 SQL Server 执行过滤工作并只返回所需的记录。

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

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