SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Exporting to Excel using 2014 SSRS not calculating correctly total seems to double


Exporting to Excel using 2014 SSRS not calculating correctly total seems to double

Author
Message
alex_martinez
alex_martinez
SSCommitted
SSCommitted (1.8K reputation)SSCommitted (1.8K reputation)SSCommitted (1.8K reputation)SSCommitted (1.8K reputation)SSCommitted (1.8K reputation)SSCommitted (1.8K reputation)SSCommitted (1.8K reputation)SSCommitted (1.8K reputation)

Group: General Forum Members
Points: 1780 Visits: 666
Hello

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 I can see the totals on the screen and print it on pdf perfectly, but when exporting to Excel the total is incorrect. I believe it has to do something with pages in Excel. Any help will be appreciate. Thank you in advance.
sgmunson
sgmunson
SSC Guru
SSC Guru (93K reputation)SSC Guru (93K reputation)SSC Guru (93K reputation)SSC Guru (93K reputation)SSC Guru (93K reputation)SSC Guru (93K reputation)SSC Guru (93K reputation)SSC Guru (93K reputation)

Group: General Forum Members
Points: 93539 Visits: 7087
In general, you should let grouping in SSRS take care of calculating totals. Using custom code should be avoided for that kind of purpose. Better yet, calculate your totals in your query for your dataset, and then all you need to do is display rows. Alternatively, a matrix or tablix can do the grouping work for you and all you need to select is the raw data.

Steve
‌(aka sgmunson)
Smile Smile Smile
Health & Nutrition
alex_martinez
alex_martinez
SSCommitted
SSCommitted (1.8K reputation)SSCommitted (1.8K reputation)SSCommitted (1.8K reputation)SSCommitted (1.8K reputation)SSCommitted (1.8K reputation)SSCommitted (1.8K reputation)SSCommitted (1.8K reputation)SSCommitted (1.8K reputation)

Group: General Forum Members
Points: 1780 Visits: 666
Yeah, in my case it's not really possible. Thanks anyways
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum








































































































































































SQLServerCentral


Search