简体   繁体   English

具有条件或条件的SSRS参数

[英]SSRS Parameter with an Either Or condition

I'm trying to implement a parameter in SSRS with a condition of an Either OR. 我正在尝试以Either OR的条件在SSRS中实现参数。 In otherwords, my Branch parameter should be able to search or lookup any branch or multiple branches, or leave it NULL or blank. 换句话说,我的Branch参数应该能够搜索或查找任何分支或多个分支,或者将其保留为NULL或空白。 Likewise, my RepCode parameter should be able to search or lookup any repcode or multiple repcodes, or leave it NULL or blank. 同样,我的RepCode参数应该能够搜索或查找任何或多个repcode,或者将其保留为NULL或空白。

Currently, I have the branch setup as a required and the repcode setup as a wildcard search 目前,我将分支设置作为必需项并将repcode设置作为通配符搜索

在此处输入图片说明

I've tried using the 'Allow Multiple Values', but can't get it to work correctly without requiring values to be entered. 我尝试使用“允许多个值”,但是如果不要求输入值就无法使其正常工作。 I would like to be able to enter value in the branch parameter or leave blank and instead enter values in the repcode parameter and return the data. 我希望能够在branch参数中输入值或留空,而在repcode参数中输入值并返回数据。 Do I need branch in (@branch) and repcode in (@repcode) to make this work? 我是否需要branch in (@branch) and repcode in (@repcode)中进行branch in (@branch) and repcode in (@repcode)才能完成这项工作?

在此处输入图片说明

If I leave the branch or repcode blank I get the following error. 如果我将分支或repcode留为空白,则会出现以下错误。

在此处输入图片说明

The business user wants the ability to enter a repcode and leave the branch blank, or enter a branch and leave the repcode blank, and be able to enter multiple values in both parameters at will. 业务用户希望能够输入repcode并将分支保留为空白,或者输入分支并将repcode保留为空白,并且能够随意在两个参数中输入多个值。

Is there a way to do this within SSRS? 有没有办法在SSRS中做到这一点?

Thanks, 谢谢,

Make these parameters nullable in SSRS 使这些参数在SSRS中可为空

In your SQL query use this pattern 在您的SQL查询中使用此模式

WHERE (branch in (@branch) and (@branch is not null and @repcode is null))
  OR (repcode in (@repcode) and (@repcode is not null and @branch is null))
  OR (branch in (@repcode) and repcode in (@repcode) and (@branch is not null and @repcode is not null))

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

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