How to return a code value into a variable

Posted by Georges Sabbagh on Stack Overflow See other posts from Stack Overflow or by Georges Sabbagh
Published on 2012-11-05T10:54:22Z Indexed on 2012/11/05 11:01 UTC
Read the original article Hit count: 363

I have the below case in my report:

Receivable: RunningValue(Fields!Receivable.Value,SUM,Nothing)

Production: code.SumLookup(LookupSet(Fields!Currency_Type.Value, Fields!Currency_Type1.Value,Fields!Gross_Premium_Amount.Value, "DataSet2"))

Rec/Prod: Receivable / Production.

Public Function SumLookup(ByVal items As Object()) As Decimal
    If items Is Nothing Then
        Return Nothing
    End If

    Dim suma As Decimal = New Decimal()
    Dim ct as Integer = New Integer()
    suma = 0
    ct = 0
    For Each item As Object In items
        suma += Convert.ToDecimal(item)
        ct += 1
    Next

    If (ct = 0) Then return 0 else return suma 
End Function

The problem is for Rec/Prod, if prod = 0 i receive error.

Ive tried to put the below condition:

IIF(code.SumLookup(LookupSet(Fields!Currency_Type.Value, Fields!Currency_Type1.Value,Fields!Gross_Premium_Amount.Value, "DataSet2"))=0,0,RunningValue(Fields!Receivable.Value,SUM,Nothing)/(code.SumLookup(LookupSet(Fields!Currency_Type.Value, Fields!Currency_Type1.Value,Fields!Gross_Premium_Amount.Value, "DataSet2"))))

but since in the false condition i am recalling code.SumLookup in order to get the value in regetting 0 for production and consiquently i get error for Rec/Prod.

how can i call code.sumlookup on time only and save its value into a variable so i dont need to call it everytime i need to check the value.

or if there any other solution please advise.

© Stack Overflow or respective owner

Related posts about reporting-services

Related posts about ssrs-2008