简体   繁体   English

SSRS参数一个标签但多个值

[英]SSRS parameter one label but multiple values

I have a query that has classify codes: if 'PC' it returns 'Compatible, if Null then it returns Unclassified, if everything else returns 'Not-Compatible'. 我有一个具有分类代码的查询:如果“ PC”返回“兼容”,如果为Null,则返回“未分类”,如果其他所有返回“不兼容”。 The alias column is "Classification". 别名列为“分类”。

> SELECT   CASE WHEN class.code IS NULL THEN 'Unclassified'
> WHEN class.Code = 'PC' THEN 'Compatible' ELSE 'Not-Compatible'
> END Classification,  FROM classification class

Now I want to set this Classification as a parameter in my SSRS report. 现在,我想将此分类设置为我的SSRS报告中的参数。

WHERE class.Code LIKE @Classification

Then in my @Classification parameter 然后在我的@Classification参数中 参数设定

So, in my report, user is prompted choose a classification, how do I get user to choose "Everything Else" that returns "Unclassified"? 因此,在我的报告中,提示用户选择分类,如何让用户选择返回“未分类”的“其他”? I can't use the alias column name "Classification" to get value. 我不能使用别名列名称“ Classification”来获取值。 If there a way to set multiple values into the label "Unclassified"? 是否可以在标签“未分类”中设置多个值?

You can build this logic into your WHERE clause. 您可以将此逻辑构建到WHERE子句中。 First change the value of Non-Compatible to "NC". 首先将“不兼容”的值更改为“ NC”。 Then you could do something like this: 然后,您可以执行以下操作:

WHERE (@Classification != 'NC' and class.Code LIKE @Classification)
  OR (@Classification = 'NC' and class.Code != 'PC')

Try modify your query to be: 尝试将查询修改为:

SELECT WhatEverColumnYouNeed  
FROM classification  
WHERE (CASE WHEN class.code IS NULL THEN 'Unclassified'  
            WHEN class.Code = 'PC' THEN 'Compatible'  
            ELSE 'Not-Compatible' END
      ) 
      IN (@Classification)

Then make you @Classification a multi-value parameter. 然后使您@Classification为多值参数。 Set available value to be Unclassified, Compatible, and Not-Compatible. 将可用值设置为“未分类”,“兼容”和“不兼容”。 Values same as Labels. 值与标签相同。

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

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