Quantcast
Channel: SQL Server Reporting Services, Power View forum
Viewing all articles
Browse latest Browse all 10045

Grand Total For Matrix Based Report

$
0
0

Hi All,

I have a matrix based report with Fields like Country ,Amount and MonthYear


So report looks like below the columns get generated dynamically :

Country     Oct 2013    Nov 2013  Dec 2013

India         25,000         25,000    25,000

England    22,000         25,000    30,000

Total         57,000         50,000    55,000


So this works perfectly fine . So next step was to get difference between the months like below :

Country     Oct 2013    Nov 2013  Dec 2013   Oct-Nov 2013          Nov - Dec 2013

India         25,000         25,000    25,000             0                               0

England    22,000         25,000    30,000          -3000                       -5000

Total         57,000         50,000    55,000


Simon_Hou Provided me a custom code for dynamically find the difference between months . Now only requirement left is the sum of the dynamically generated month difference column . As the columns are generated based on a custom code it's not allowing me to do a sum  on it.

Desired Output

Country     Oct 2013    Nov 2013  Dec 2013   Oct-Nov 2013          Nov - Dec 2013

India         25,000         25,000    25,000             0                               0

England    22,000         25,000    30,000          -3000                       -5000

Total         57,000         50,000    55,000         -3000                        -5000



Can any one please advice me how to do sum for the dynamically generated custom code column .





Code is below it might help some1 else(Simon_Hou)

Private queueLength As Integer = 2
Private queueSum As Double = 0
Private queueFull As Boolean = False
Private idChange As String=""
Dim queue As New System.Collections.Generic.Queue(Of Integer)
Public Function CumulativeQueue(ByVal currentValue As Integer,id As String) As Object
Dim removedValue As Double = 0
If idChange <> id then
        ClearQueue()
                idChange = id 
                queueSum = 0 
                queueFull = False
                CumulativeQueue(currentValue,id)
Else  
                If queue.Count >= queueLength Then
                                removedValue = queue.Dequeue()
                End If
                queueSum += currentValue
                queueSum -= removedValue
                queue.Enqueue(currentValue)
                If queue.Count < queueLength Then
                Return Nothing
                ElseIf queue.Count = queueLength And queueFull = False Then
                queueFull = True
                Return (queueSum-currentValue-currentValue) 
                Else
                Return (queueSum-currentValue-currentValue) 
                End If
End If
End Function
public function ClearQueue()
Dim i as Integer
Dim n as Integer = Queue.Count-1
for i=n To 0 Step-1
                queue.Dequeue()
next i
End function


Thanks in Advance

Priya


Viewing all articles
Browse latest Browse all 10045

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>