我正在尝试修改以下代码,这为报告文件中的查询提供了价值。如果存在有限数量的值,则旧值可以工作,对于任意数量的值,修改后应该是通用的。
<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的新人。很高兴得到任何帮助。感谢。
答案 0 :(得分:0)
您是否尝试将参数选择放在一个字符串中?
您可以使用 JOIN 将它们放在一个文本行中:
=Join(Parameters!TagHum.Value, ";")
https://msdn.microsoft.com/en-us/library/aa337292(SQL.90).aspx