Exporting to Excel not getting the correct Total using custom code

  • Sorry, please see below for my post disregard old post.  Thank you.

    Hello

    I am having an issue when exporting to Excel I am not getting the correct total amount.  I get the correct amount on the screen or exporting to pdf.  Below is my code

    Custom Code

    Public Shared Value as Integer=0Public Shared Function GetValue(Item as Integer) as Integer

    value= value + Item

    return Item

    End Function

    Public Shared Function GetTotal()

    return value

    End Function

    On the row to store the numbers I here is my code -

    =Code.GetValue(IIF(IsNothing(Lookup(Fields!CustomerName.Value, Fields!Customer_Name.Value,  Fields!BudgetPeriod.Value, "DataSetSQL_Budget")),0, Lookup(Fields!CustomerName.Value, Fields!Customer_Name.Value,  Fields!BudgetPeriod.Value, "DataSetSQL_Budget")))

    Finally on the total row I input the total using
    =Code.GetTotal()

    Now it works perfect on the screen or print it or exported to pdf file, but when exporting to Excel the total is incorrect. It seems to double.  I believe it has to do something with pages in Excel.  Any help will be appreciate.  Thank you in advance.

  • It's more likely that the code is executed twice - on the preview and then again on the export.
    Refer to the example by ScottRFrost in this link - that's generally how I've seen reports not hit similar issues:
    SSRS Code Variables resetting on new page

    Sue

  • Thanks Sue,  I appreciate your tip I will look into that. 🙂

Viewing 3 posts - 1 through 2 (of 2 total)

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