Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Exporting an SSRS Report with Custom Code shows 0

Posted on 2010-08-20
5
Medium Priority
?
2,086 Views
Last Modified: 2016-02-15
Hey All,

I've checked else where on google and can't seem to find anything on this topic so I figured I'd ask it here.  I have an SSRS report with some custom code to calculate the Top N sum (needed to use custom code since the SUM function sums the entire dataset and not the filtered dataset).  The code is below for reference but I know it's working, as on the preview tab in Visual Studios 2008's ssrs report builder it displays the total fine.  The problem is when I export the report (to any format, but looking specifically for excel), the value in the total shows 0.  I was under the impression that the rendered version is what is exported, but it seems I was wrong, but even so, shouldn't the export save the same result that the preview shows?

Has anyone seen this issue, and figured out a solution?  Thankfully I tested the export before doing my sums for each column of the report (there are roughly 25 columns which need to be summed, and only finding out this after would have been terrible news).

The data is coming from an Analysis Services cube.

Unfortunately I cannot attach a sample of the report as it contains confidential information.

Thank you in advance!

Public total as Integer
Public totalField as new System.Collections.HashTable

Public function AddTotal(ByVal product as String,Byval value as Integer)
	if (totalField(product) is nothing) then
		totalField.Add(product,value)
	else
		total = totalField(product)
		total = total + value
		totalField.Remove(product)
		totalField.Add(product,total)
	end if	
End function

Public function GetTotal(Byval product As String) As Integer
	return totalField(product)
End function

Open in new window

0
Comment
Question by:lasenzait
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 10

Expert Comment

by:itcouple
ID: 33489253
Hi

I haven't come across this issue before but if you use SSAS as your source it might be easier to write MDX which will give you the answer instead of using code in SSRS. MDX usually handles complexity very well! Would that work for you?

Regards
Emil
0
 
LVL 27

Expert Comment

by:planocz
ID: 33490354
When you use VB code in 2008 you are better to use code like below....
Public total as Integer =0
Public totalField as new System.Collections.HashTable
 Public function AddTotal(ByVal product as String,Byval value as Integer) as Object
if IsNothing(totalField(product)) then
 totalField.Add(product,value)
else
 total = totalField(product)
total += value
totalField.Remove(product)
 totalField.Add(product,total)
return total
end if
return Nothing
End function

 Public function GetTotal(Byval product As String) As Integer
return totalField(product)
End function
0
 

Author Comment

by:lasenzait
ID: 33525371
Hello,

The reason I'm not doing it directly in MDX, is because the TOP N is a parameter value that the user can select from a drop down.  I had originally made it so that that parameter goes to the dataset for the MDX, but it kept giving me errors, and eventually I was told to use the filter property on the table.

This works fine for displaying in the SSRS viewer, it's only on export that it disappears, and the users here generally export to excel.

I'll change the code to add the return nothing, but I don't see that as being the source of the issue.

Thank you, and if you have any other ideas, please let me know.
0
 
LVL 10

Expert Comment

by:itcouple
ID: 33540069
Hi

If you decide to go MDX route post the code which gives you errors and I might be able to help.

Regards
Emil
0
 

Accepted Solution

by:
lasenzait earned 0 total points
ID: 33645562
Just as an update, I found the solution to the exporting problem:

When I called the Code.GetTotal function in a text box, it would render fine in the SSRS preview, however it would not export.  By calling Code.GetTotal in a variable declared at the group level, and then refering to that variable in the text box, the value exports as expected.

So the solution was to call the code from a variable and then display that variable, rather than just call the code directly in the cell.
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A recent question popped up and the discussion heated up regarding updating a COMMENTS (TXT) field in a table using SSRS. http://www.experts-exchange.com/Microsoft/Development/MS-SQL-Server/MS-SQL_Reporting/Q_27475269.html?cid=1572#a37227028 (htt…
A recent questions about how to add SSRS named instances, couldn't find any that talks about SQL server 2008, anyway I decided to help by creating some screen shots. The installation is straightforward, you just pop the SQL server 2008 installati…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …

688 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question