2015-12-07 36 views
1

我試圖在SSRS中實現一個參數或條件的任一或。換句話說,我的分支參數應該能夠搜索或查找任何分支或多個分支,或將其留空或空白。同樣,我的RepCode參數應該能夠搜索或查找任何代碼或多個代碼,或保留NULL或空白。SSRS參數與任一或條件

目前,我有分支設置爲必需和repcode設置爲通配符搜索

enter image description here

我使用「允許多個值」試過,但它不能得到無需輸入值即可正常工作。我希望能夠在分支參數中輸入值或保留爲空,並在repcode參數中輸入值並返回數據。我需要branch in (@branch) and repcode in (@repcode)才能完成這項工作嗎?

enter image description here

如果我離開了分支機構或repcode空白我碰到下面的錯誤。

enter image description here

業務用戶要輸入一個repcode和離開分支空白,或者輸入一個分支,離開repcode空白,並能隨意在兩個參數輸入多個值的能力。

有沒有辦法在SSRS內做到這一點?

感謝,

回答

1

使這些參數可爲空在SSRS

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