Report Design
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Report Design
Message Icon Topic: One to Many Summing Totals Post Reply Post New Topic
Author Message
DoubleD
Newbie
Newbie


Joined: 26 Sep 2012
Online Status: Offline
Posts: 17
Quote DoubleD Replybullet Topic: One to Many Summing Totals
     Posted: 18 Mar 2014 at 10:32am
I need to write a report that includes a  one to many relationship on two tables

I started simple access the table with one (inventory) I link it to a table with a 1 to many relationship (InvMovement)

I group  on and to  sum on qty move  - Life is good

Now I need to know how many I have on hand so I link over to my Warehouse and yup its a one to many so now I have 2 one to many relationships here 

Needless to say mt totals are all whacked out

Given the tables

INV
1
2

INV Movement
1         10
1         20
2         15

INV  Warehouse     QTY
1            A                  3
1            B                  5
1            C                  2
2            A                  10
2            B                  10

Crystal builds

Inv    Move  WH    QTY
1          10      A      3
1          10      B      5
1          10      C      2
1          20      A      3
1          20      B      5
1          20      C      2
2          15      A      10
2          15      B      10


The report should show

INV    Tot Moved    On hand
1            30                 10
2            15                 20


How would you go about making the report total correctly  I get a total of 90 movements for INV 1 and 20 on hand  

For inv 2 I get total movement of 30 and a qty of 20


Edited by DoubleD - 19 Mar 2014 at 5:04am
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4374
Quote lockwelle Replybullet Posted: 21 Mar 2014 at 5:09am
obviously it's your joins. the 2 solutions that I can think of off the top of my head are 1) stored procedure where you can control the summing so that duplicate records are ignored 2) subreports for the total moved and total on hand amounts (or just 1 subreport for one of the totals, the other total will be fine)...

perhaps there is one other, which would be shared variables doing the summing in the background, but that might get really messy as you would have to distinguish one 'set' of data from another, and what if you moved the same amount twice for the same inventory item (which seems a likely occurrence)...so this may not be that viable.

HTH
IP IP Logged
DoubleD
Newbie
Newbie


Joined: 26 Sep 2012
Online Status: Offline
Posts: 17
Quote DoubleD Replybullet Posted: 21 Mar 2014 at 5:35am
Originally posted by lockwelle

obviously it's your joins. the 2 solutions that I can think of off the top of my head are 1) stored procedure where you can control the summing so that duplicate records are ignored 2) subreports for the total moved and total on hand amounts (or just 1 subreport for one of the totals, the other total will be fine)...

perhaps there is one other, which would be shared variables doing the summing in the background, but that might get really messy as you would have to distinguish one 'set' of data from another, and what if you moved the same amount twice for the same inventory item (which seems a likely occurrence)...so this may not be that viable.

HTH



Hey thanks for the input. I don't have the ability (or knowledge) to use stored procedures. If I had access rights would create a view with some joins to get the data but they have me locked out.

I basically went with a main report and a subreport  but using 2 subreports also worked.
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