I have a need to build a list of values that get reported on a line from
multiple records. I've tried the following code:
Dim myList as String
Function AddList(myVal as String) as String
If myList <> "" Then
myList = myList + ", "
End If
myList = myList + myVal
Return myList
End Function
Function ClearList() As String
myList = ""
Return myList
End Function
Function GetList() as String
Return myList
End Function
I put ClearList in the group header, BuildList in the details section, and
GetList in the Group footer. When I run the report, the header is blank, the
detail section I see the string building, but in the footer I get a blank.
Is this an evaluation time issue and is there a way to alter that? Or is
there a better solution in RS?I can solve this in SQL Server using a UDF but am still looking for a
Reporting Services Solution.
UDF:
CREATE FUNCTION SubList (@.valueId as INT)
RETURNS varchar(500)
WITH SCHEMABINDING
AS
BEGIN
DECLARE @.list varchar(500)
SELECT @.list = ISNULL(@.list +', ','') + mySubValue FROM dbo.SubValues WHERE
valueId=@.valueId
RETURN @.list
END
Usage:
SELECT valueId, myValue, dbo.SubList(valueId) AS myList
FROM [Values]
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment