Reset custom code values at group level SSRS

  • Hi,

    I need to calculate difference between two columns in a matrix. I need to do this for two different values like total counts and amount separately. I have achieved that with the following code but I need to reset these values for each group. Otherwise the previous value is taken from the previous. How do I reset these values for every location.? Here is the custom code for the same

    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 Double,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

     

    Here is how I am calling it from the cell

    =Code.CumulativeQueue(SUM(Fields!Stops.Value),Fields!Location.Value)

    But I need todo find the difference for 2 different columns for ex: trips and amount columns

    Thanks

    ylsv

Viewing 0 posts

You must be logged in to reply to this topic. Login to reply