Report Design
 Crystal Reports Forum : Crystal Reports for Visual Studio 2005 and Newer : Report Design
Message Icon Topic: Sum field shows count instead of summary Post Reply Post New Topic
Author Message
stanleykapo
Newbie
Newbie
Avatar

Joined: 13 Apr 2009
Location: Slovakia
Online Status: Offline
Posts: 3
Quote stanleykapo Replybullet Topic: Sum field shows count instead of summary
    Posted: 13 Apr 2009 at 11:06pm
Hi, I haven't found this anywhere so I post it here.

I am using CR with Visual Sutdio 2008 and I have encountered the following problem:

To make it easier to inderstand let's suppose I want to have six collumns in my report - customer, amount(of certain goods), name of the good, place(customer wants the good), the price for one unit of the good, total price.
I want report to group the rows by 'customer', and for each 'customer' count the sum of 'amount' and 'price'.
I designed the report using the wizard, source for the report is '.NET Object'(members of a class). When I look at the 'Main Report Preview' in VS2008 everything works fine.
The problem comes when I create a windows form with crystal report viewer and load it with data. The code creates a new instance of the report, sets its data source to an ArrayList, and then set the report source for the report viewer to this instance.
I have done this many time and it always worked. But in this special case, the two summary fields('amount' and 'price' just don't work. They show count instead of sum.

I have no idea what to do, to me everything seems to be set allright, report shows correct data, just the summary fields don't work. Please help, I am desperate.
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4372
Quote lockwelle Replybullet Posted: 14 Apr 2009 at 6:32am
First thought is the fields are being interpretted as strings by Crystal...and you can't sum a string. 
 
If this is the case, it's just not pretty, but you can sum the values by hand with formulas.  Hopefully it is possible to change the array designator to numeric for those fields ( I have seen this when working with sample XML files where everything is a string)
IP IP Logged
stanleykapo
Newbie
Newbie
Avatar

Joined: 13 Apr 2009
Location: Slovakia
Online Status: Offline
Posts: 3
Quote stanleykapo Replybullet Posted: 14 Apr 2009 at 8:51am
Unfortunately this is not the case - in the source class they are declared as double.
I also believe that if it was the case you describe, it also would not work in the 'Main Report Preview' in VS.
Thank you anyway, lockwelle.
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4372
Quote lockwelle Replybullet Posted: 15 Apr 2009 at 6:30am
I don't use the arrayList object, but in looking at msdn documentation, it states that "when reading the value from an ArrayList you need to explicitly cast it to the data type ".  sounds like it is stored as a string in the array and then cast to the appropriate datatype.  Crystal doesn't know to cast.
 
do any of your number fields sum in aggregate functions in crystal?
 
just wondering.
IP IP Logged
stanleykapo
Newbie
Newbie
Avatar

Joined: 13 Apr 2009
Location: Slovakia
Online Status: Offline
Posts: 3
Quote stanleykapo Replybullet Posted: 15 Apr 2009 at 9:43pm
Yes, I did it analogically with other reports and it works fine.
It also works in 'Main Report Preview' so I believe that when you have objects stored in an ArrayList, Crystal is able to decide about types.
I got an idea that this might not be problem of the sum fuction but something else, as the report in crystalViewer also does not show proper formatting of DateTime item(it shows default instead of what I chose).
And that is a real mystery.
IP IP Logged
Post Reply Post New Topic
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum



This page was generated in 0.031 seconds.