开发者

SQL Reporting 2008; Check if an Array Contains a String

In SQL Reporting 2008 how can I determin开发者_运维问答e if an Array Contains a String?

Example, I wish the following to return "1":

IIf(Split("a,b,c", ",").CONTAINS("a"), "1", "0")

What may be used in replace of the above CONTAINS function? Is it impossible? This value'd be the FilterExpression for my table. Its purpose is to decide what to show and what to hide.


If you are looking for an answer only in an expression, I am not positive. However, you can write .Net methods and call them just like expressions from a custom dll or a "code" section of the report. If you use built-in code, you can do something like the following:

http://www.vbforums.com/showthread.php?t=558440

Creating inline code or referencing an assembly in SSRS:

http://bryantlikes.com/pages/824.aspx

UPDATE: Example to get your delimited values from your concatenated string:

http://www.dotnetperls.com/split-vbnet

UPDATE:

Here is a function you can use. You put it in the code section of the report:

Public Function Contains(ByVal ItemToCheck As String, ByVal CommaValuesList As String, ByVal delimeter As Char) As Boolean
    Dim commaValues() As String = Split(CommaValuesList, delimeter, -1, CompareMethod.Text)

    For Each commavalue As String In commaValues
        If ItemToCheck.ToLower.Trim = commavalue.ToLower.Trim Then
            Return True
        End If
    Next

    Return False
End Function

Use the following syntax to reference it:

=code.Contains(param1,param2,param3)


Let's use MyLettersParameter as a multiselect parameter. To determine if it contains "a" use:

=Array.IndexOf(Parameters!MyLettersParameter.Value, "a") > -1

The above code returns true or false. To return "1" use:

=IIf(Array.IndexOf(Parameters!MyLettersParameter.Value, "a") > -1, "1", "0")
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜