Report Design
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Report Design
Message Icon Topic: Problem with SUM() Post Reply Post New Topic
Author Message
imeldajunk
Newbie
Newbie
Avatar

Joined: 16 Feb 2009
Location: Ireland
Online Status: Offline
Posts: 6
Quote imeldajunk Replybullet Topic: Problem with SUM()
     Posted: 16 Feb 2009 at 1:13pm
Hi all,
 
I have a group booking. This contains a number of different bookings (BookingIDs) under the one group(#). A particular booking will have a single booking fee. A booking can contain a number of line items.
 
I want a report that will show all bookings under a single group and show all lines relating to each booking, as well as show the booking fee/s that apply. E.G.
 
Group#
BookID
BookFee
ABC
123
5
ABC
456
10
ABC
789
0
BookID
Desc
123
B&B
123
Full Board
123
Half Board
BookID
Desc
456
B&B
BookID
Desc
789
B&B
 
 
 
 
 
So Group# ABC contains 3 Bookings: i. 123 has a BookingFee of €5 and contains 3 line items ii. 456 and iii. 789 have 1 line each with 456 having a €10 BookingFee.
 
I have my report A. by Group# and B. by BookID. I am showing my BookDets in the report Details section and I want to show a Sum of my Booking Fee in the Group# Footer Section. My total Booking Fee should be €15 however it is showing €25. This is because the data selection for my report i.e.

SELECT tblBookHdr.ID, tblBookHdr.GroupNo, tblBookHdr.BookingFee, tblBookDets.Desc

FROM tblBookHdr INNER JOIN tblBookDets ON tblBookHdr.ID = tblBookDets.BookingID

WHERE (((tblBookHdr.GroupNo)=’ABC’));

returns:
 

Group#

BookID

BookFee

Desc

ABC

123

5

B&B

ABC

123

5

Full Board

ABC

123

5

Half Board

ABC

456

10

B&B

ABC

789

0

B&B

 
So the report is showing a total Booking Fee of €25. How do I fix the report to display the correct amount?
 
Thanking you in advance,
Mel.
 
 
  
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4374
Quote lockwelle Replybullet Posted: 16 Feb 2009 at 1:37pm
simplest way is with shared variables and formulae.
 
in general, there are 3 formulae, 1 to reset the value to 0 when the Group# changes, 1 to display the total of the booking fees and the third to actually accumulate the booking fee.  In this case, i would put it in the group header for the bookID, and would be pretty simple...
 
shared numbervar BookingFee := BookingFee + {BookingFeeField};
""   //I put the quotes so that the formula is 'invisible' when displayed.
 
Hope this helps
IP IP Logged
imeldajunk
Newbie
Newbie
Avatar

Joined: 16 Feb 2009
Location: Ireland
Online Status: Offline
Posts: 6
Quote imeldajunk Replybullet Posted: 18 Feb 2009 at 1:37pm
Thanks lockwelle, I'll give it a try.
IP IP Logged
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