Groups | Blog | Home
all groups > sql server reporting services > november 2005 >

sql server reporting services : howto reference previous sums in recursive hierarchy


gergev
11/4/2005 1:51:04 PM
Ok, I figured how to do a recursive hierachy. Plus through a lot of digging
managed to come compute the sum at each level. BTW, it works as aspected in
that each level up the hiearchy tree includes the the sums below it as in

Region Sales
-----------------------------
West 150
Washington 100
Puget Sound 75 (75/150)*100 <--- ??
Cascades 25 (25/150)*100
Oregon 50
East 200
New York 200 (200/150)*100

?? Is there any way to refer to the 'sum' accumulated for the West region
and use
it for calculations of percentages later on.

Something like is really simple to do in ActiveReports but I have not found
any way to do in Reporting Services.

Any ideas?
capricorn
11/21/2005 12:08:04 PM
I had the same problem of trying to compute the sum at each level of the
hierarchy so please let me know how you were able to include the sums below
each level of the hierarchy? Thanks.
--
-RB
:)


[quoted text, click to view]
jj
11/28/2005 11:56:06 AM

Have not accessed this forum in a while but to answer the question, I
created a custom assembly. The custom assembly basically implemented a hash
table. Each row in the dataset was codified to have a unique value. To the
unique value I would concatenate a unique column identifier. Together these
made up a unique key that I could use to store a value in the hash table.
Later then I could retrieve any value by using the desired key. (vb.net code
below; UGH; I hate vb anything but the customer didn't know c# so didn't have
a choice)

Option Strict On

Imports System
Imports System.Collections



Public Class GlobalStorage

Shared GlobalCollection As New Hashtable

Public Shared Function Save(ByVal keyType As String, ByVal fieldCode As
String, ByVal keyIntValue As Integer) As Integer
Dim keyName As String

keyName = keyType + fieldCode

If GlobalCollection.ContainsKey(keyName) Then
' the key already exists, just update the value
GlobalCollection.Item(keyName) = keyIntValue
Else
' the key does NOT exist, add both the key and the value to the
collection
GlobalCollection.Add(keyName, keyIntValue)
End If

Return (keyIntValue)
End Function


Public Shared Function Retrieve(ByVal keyName As String) As Integer
If GlobalCollection.ContainsKey(keyName) Then
' the key exists return the value
Return CType(GlobalCollection.Item(keyName), Integer)
Else
' return 0 so the formating of the report will show blank space
Return (0)
End If
End Function

End Class

There are a bunch of other things that you have to implement like the code
in the field expressions, and configuring RS to be able to use the assy. All
in all, a real pain. I sure miss ActiveReports. What took a couple of hours
in ActiveReports may take days in Reporting Services, and this is of course,
Darrell
12/7/2005 7:58:03 PM
Can you explain how you were able to do recursive sums? I have a report that
I would like to do the same thing with.

regards

[quoted text, click to view]
Ray D
12/19/2005 7:17:02 AM
Guys from MS, can you comment jj's solution? As I understand this is a quite
common problem.

[quoted text, click to view]
Ray D
12/19/2005 7:39:01 AM
I've found undocumented parameter "recursive" in the Sum function, but I have
a matrix with the hierachy, and this parameter works fine only when there is
AddThis Social Bookmark Button