简体   繁体   English

基于参数的SSRS报告过滤

[英]SSRS report filtering based on a parameter

I have an SSRS report with a field called SetGroup.我有一个名为 SetGroup 的字段的 SSRS 报告。 Each row has a SetGroup value of either 'Group 1' or 'Group 2'.每行都有一个“组 1”或“组 2”的 SetGroup 值。 I have a parameter called Term.我有一个名为 Term 的参数。 If Term = 'All' then only show Group 1 records, otherwise show Group 2. I am trying to set up a filter to do this, but it seems I need it to be like IF-THEN-ELSE.如果 Term = 'All' 则仅显示第 1 组记录,否则显示第 2 组。我正在尝试设置一个过滤器来执行此操作,但似乎我需要它像 IF-THEN-ELSE。 I have the filter here, but how do I now tell it to only show the Group 1 records ELSE Group 2?我这里有过滤器,但我现在如何告诉它只显示第 1 组记录 ELSE 第 2 组?

在此处输入图像描述

I have two ideas and I'm not sure if either are possible or how to do them.我有两个想法,我不确定是否有可能或如何去做。 Maybe one of you has an idea.也许你们中的一个人有一个想法。

1.) Could I put a CASE in my WHERE clause? 1.) 我可以在 WHERE 子句中加入 CASE 吗? Something along the lines of this?类似的东西? SQL Server says this is bad syntax because of the extra = operators. SQL 服务器说这是错误的语法,因为额外的 = 运算符。

WHERE CASE WHEN @Term = 'All' THEN j.SetGroup = 'Group 1' ELSE j.SetGroup = 'Group 2' END

2.) Could I put IIF formulas in the Expression and in the Value boxes of my filter with the bottom playing off the top one? 2.) 我可以将 IIF 公式放入我的过滤器的表达式和值框中,底部播放顶部一个吗?

I knew it there was a simple solution in there somewhere.我知道那里有一个简单的解决方案。

WHERE j.SetGroup = CASE
    WHEN @Term = 'All' THEN 'Group 1'
    ELSE 'Group 2'
END

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

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