2016-10-04 76 views
0

我試圖修改下面的代碼,它爲報告文件中的查詢提供了值。如果存在有限數量的值,則舊的方法工作,對於任意數量的值,修改應該是通用的。多值參數作爲SSRS中的VBScript函數輸入

<Value>=Switch(Parameters!TagHum.Count-20=1, Parameters!TagHum.Value(0) 
,Parameters!TagHum.Count-20=2, Parameters!TagHum.Value(0) & ";" & Parameters!TagHum.Value(1) 
,Parameters!TagHum.Count-20=3, Parameters!TagHum.Value(0) & ";" & Parameters!TagHum.Value(2) & ";" & Parameters!TagHum.Value(1) 
,Parameters!TagHum.Count-20=4, Parameters!TagHum.Value(0) & ";" & Parameters!TagHum.Value(3) & ";" & Parameters!TagHum.Value(2) & ";" & Parameters!TagHum.Value(1) 
,Parameters!TagHum.Count-20=5, Parameters!TagHum.Value(0) & ";" & Parameters!TagHum.Value(4) & ";" & Parameters!TagHum.Value(3) & ";" & Parameters!TagHum.Value(2) & ";" & Parameters!TagHum.Value(1) 
,Parameters!TagHum.Count-20=6, Parameters!TagHum.Value(0) & ";" & Parameters!TagHum.Value(5) & ";" & Parameters!TagHum.Value(4) & ";" & Parameters!TagHum.Value(3) & ";" & Parameters!TagHum.Value(2) & ";" & Parameters!TagHum.Value(1) 
,Parameters!TagHum.Count-20=7, Parameters!TagHum.Value(0) & ";" & Parameters!TagHum.Value(6) & ";" & Parameters!TagHum.Value(5) & ";" & Parameters!TagHum.Value(4) & ";" & Parameters!TagHum.Value(3) & ";" & Parameters!TagHum.Value(2) & ";" & Parameters!TagHum.Value(1) 
,Parameters!TagHum.Count-20=8, Parameters!TagHum.Value(0) & ";" & Parameters!TagHum.Value(7) & ";" & Parameters!TagHum.Value(6) & ";" & Parameters!TagHum.Value(5) & ";" & Parameters!TagHum.Value(4) & ";" & Parameters!TagHum.Value(3) & ";" & Parameters!TagHum.Value(2) & ";" & Parameters!TagHum.Value(1) 
,Parameters!TagHum.Count-20=9, Parameters!TagHum.Value(0) & ";" & Parameters!TagHum.Value(8) & ";" & Parameters!TagHum.Value(7) & ";" & Parameters!TagHum.Value(6) & ";" & Parameters!TagHum.Value(5) & ";" & Parameters!TagHum.Value(4) & ";" & Parameters!TagHum.Value(3) & ";" & Parameters!TagHum.Value(2) & ";" & Parameters!TagHum.Value(1) 
,Parameters!TagHum.Count-20=10, Parameters!TagHum.Value(0) & ";" & Parameters!TagHum.Value(9) & ";" & Parameters!TagHum.Value(8) & ";" & Parameters!TagHum.Value(7) & ";" & Parameters!TagHum.Value(6) & ";" & Parameters!TagHum.Value(5) & ";" & Parameters!TagHum.Value(4) & ";" & Parameters!TagHum.Value(3) & ";" & Parameters!TagHum.Value(2) & ";" & Parameters!TagHum.Value(1) 
,Parameters!TagHum.Count-20=11, Parameters!TagHum.Value(0) & ";" & Parameters!TagHum.Value(10) & ";" & Parameters!TagHum.Value(9) & ";" & Parameters!TagHum.Value(8) & ";" & Parameters!TagHum.Value(7) & ";" & Parameters!TagHum.Value(6) & ";" & Parameters!TagHum.Value(5) & ";" & Parameters!TagHum.Value(4) & ";" & Parameters!TagHum.Value(3) & ";" & Parameters!TagHum.Value(2) & ";" & Parameters!TagHum.Value(1) 
,Parameters!TagHum.Count-20=12, Parameters!TagHum.Value(0) & ";" & Parameters!TagHum.Value(11) & ";" & Parameters!TagHum.Value(10) & ";" & Parameters!TagHum.Value(9) & ";" & Parameters!TagHum.Value(8) & ";" & Parameters!TagHum.Value(7) & ";" & Parameters!TagHum.Value(6) & ";" & Parameters!TagHum.Value(5) & ";" & Parameters!TagHum.Value(4) & ";" & Parameters!TagHum.Value(3) & ";" & Parameters!TagHum.Value(2) & ";" & Parameters!TagHum.Value(1) 
,Parameters!TagHum.Count-20=13, Parameters!TagHum.Value(0) & ";" & Parameters!TagHum.Value(12) & ";" & Parameters!TagHum.Value(11) & ";" & Parameters!TagHum.Value(10) & ";" & Parameters!TagHum.Value(9) & ";" & Parameters!TagHum.Value(8) & ";" & Parameters!TagHum.Value(7) & ";" & Parameters!TagHum.Value(6) & ";" & Parameters!TagHum.Value(5) & ";" & Parameters!TagHum.Value(4) & ";" & Parameters!TagHum.Value(3) & ";" & Parameters!TagHum.Value(2) & ";" & Parameters!TagHum.Value(1) 
,Parameters!TagHum.Count-20=14, Parameters!TagHum.Value(0) & ";" & Parameters!TagHum.Value(13) & ";" & Parameters!TagHum.Value(12) & ";" & Parameters!TagHum.Value(11) & ";" & Parameters!TagHum.Value(10) & ";" & Parameters!TagHum.Value(9) & ";" & Parameters!TagHum.Value(8) & ";" & Parameters!TagHum.Value(7) & ";" & Parameters!TagHum.Value(6) & ";" & Parameters!TagHum.Value(5) & ";" & Parameters!TagHum.Value(4) & ";" & Parameters!TagHum.Value(3) & ";" & Parameters!TagHum.Value(2) & ";" & Parameters!TagHum.Value(1) 
,Parameters!TagHum.Count-20=15, Parameters!TagHum.Value(0) & ";" & Parameters!TagHum.Value(14) & ";" & Parameters!TagHum.Value(13) & ";" & Parameters!TagHum.Value(12) & ";" & Parameters!TagHum.Value(11) & ";" & Parameters!TagHum.Value(10) & ";" & Parameters!TagHum.Value(9) & ";" & Parameters!TagHum.Value(8) & ";" & Parameters!TagHum.Value(7) & ";" & Parameters!TagHum.Value(6) & ";" & Parameters!TagHum.Value(5) & ";" & Parameters!TagHum.Value(4) & ";" & Parameters!TagHum.Value(3) & ";" & Parameters!TagHum.Value(2) & ";" & Parameters!TagHum.Value(1) 
,Parameters!TagHum.Count-20=16, Parameters!TagHum.Value(0) & ";" & Parameters!TagHum.Value(15) & ";" & Parameters!TagHum.Value(14) & ";" & Parameters!TagHum.Value(13) & ";" & Parameters!TagHum.Value(12) & ";" & Parameters!TagHum.Value(11) & ";" & Parameters!TagHum.Value(10) & ";" & Parameters!TagHum.Value(9) & ";" & Parameters!TagHum.Value(8) & ";" & Parameters!TagHum.Value(7) & ";" & Parameters!TagHum.Value(6) & ";" & Parameters!TagHum.Value(5) & ";" & Parameters!TagHum.Value(4) & ";" & Parameters!TagHum.Value(3) & ";" & Parameters!TagHum.Value(2) & ";" & Parameters!TagHum.Value(1) 
,Parameters!TagHum.Count-20=17, Parameters!TagHum.Value(0) & ";" & Parameters!TagHum.Value(16) & ";" & Parameters!TagHum.Value(15) & ";" & Parameters!TagHum.Value(14) & ";" & Parameters!TagHum.Value(13) & ";" & Parameters!TagHum.Value(12) & ";" & Parameters!TagHum.Value(11) & ";" & Parameters!TagHum.Value(10) & ";" & Parameters!TagHum.Value(9) & ";" & Parameters!TagHum.Value(8) & ";" & Parameters!TagHum.Value(7) & ";" & Parameters!TagHum.Value(6) & ";" & Parameters!TagHum.Value(5) & ";" & Parameters!TagHum.Value(4) & ";" & Parameters!TagHum.Value(3) & ";" & Parameters!TagHum.Value(2) & ";" & Parameters!TagHum.Value(1) 
,Parameters!TagHum.Count-20=18, Parameters!TagHum.Value(0) & ";" & Parameters!TagHum.Value(17) & ";" & Parameters!TagHum.Value(16) & ";" & Parameters!TagHum.Value(15) & ";" & Parameters!TagHum.Value(14) & ";" & Parameters!TagHum.Value(13) & ";" & Parameters!TagHum.Value(12) & ";" & Parameters!TagHum.Value(11) & ";" & Parameters!TagHum.Value(10) & ";" & Parameters!TagHum.Value(9) & ";" & Parameters!TagHum.Value(8) & ";" & Parameters!TagHum.Value(7) & ";" & Parameters!TagHum.Value(6) & ";" & Parameters!TagHum.Value(5) & ";" & Parameters!TagHum.Value(4) & ";" & Parameters!TagHum.Value(3) & ";" & Parameters!TagHum.Value(2) & ";" & Parameters!TagHum.Value(1) 
,Parameters!TagHum.Count-20=19, Parameters!TagHum.Value(0) & ";" & Parameters!TagHum.Value(18) & ";" & Parameters!TagHum.Value(17) & ";" & Parameters!TagHum.Value(16) & ";" & Parameters!TagHum.Value(15) & ";" & Parameters!TagHum.Value(14) & ";" & Parameters!TagHum.Value(13) & ";" & Parameters!TagHum.Value(12) & ";" & Parameters!TagHum.Value(11) & ";" & Parameters!TagHum.Value(10) & ";" & Parameters!TagHum.Value(9) & ";" & Parameters!TagHum.Value(8) & ";" & Parameters!TagHum.Value(7) & ";" & Parameters!TagHum.Value(6) & ";" & Parameters!TagHum.Value(5) & ";" & Parameters!TagHum.Value(4) & ";" & Parameters!TagHum.Value(3) & ";" & Parameters!TagHum.Value(2) & ";" & Parameters!TagHum.Value(1) 
,Parameters!TagHum.Count-20=20, Parameters!TagHum.Value(0) & ";" & Parameters!TagHum.Value(19) & ";" & Parameters!TagHum.Value(18) & ";" & Parameters!TagHum.Value(17) & ";" & Parameters!TagHum.Value(16) & ";" & Parameters!TagHum.Value(15) & ";" & Parameters!TagHum.Value(14) & ";" & Parameters!TagHum.Value(13) & ";" & Parameters!TagHum.Value(12) & ";" & Parameters!TagHum.Value(11) & ";" & Parameters!TagHum.Value(10) & ";" & Parameters!TagHum.Value(9) & ";" & Parameters!TagHum.Value(8) & ";" & Parameters!TagHum.Value(7) & ";" & Parameters!TagHum.Value(6) & ";" & Parameters!TagHum.Value(5) & ";" & Parameters!TagHum.Value(4) & ";" & Parameters!TagHum.Value(3) & ";" & Parameters!TagHum.Value(2) & ";" & Parameters!TagHum.Value(1) 
) </Value> 

它可以通過循環來解決,但SSRS不支持週期,所以我想我可以包括VBS與功能的文件是這樣的:

Public Shared Function TagTempHum_parse(Param_count,Param_values) 
    Dim arr1() 
    Dim result 
    Dim TagCount = Param_count - 20 
    Dim i = 0 
    For i = 1 To TagCount 
     result = result & Param_values(i) & ";" 
    Next 
    result = Left(result, Len(result) - 1) 
    TagTempHum_parse = result 
    End Function 

,並在SSRS調用這個函數:

<Value> 
=Code.TagTempHum_parse(Parameters!TagHum.Count,Parameters!TagHum.Value) 
</Value> 

我的第一個問題是:這種方法甚至有可能嗎? 第二個問題:我需要將所有參數!TagHumValue值傳遞給函數,當我不知道有多少個參數時,我該如何做到這一點?

對不起,如果我的問題是愚蠢的,我在SSRS新。對任何幫助感到高興。謝謝。

回答