Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: Distinctly Sum Fields Post Reply Post New Topic
Author Message
mhuman
Newbie
Newbie
Avatar

Joined: 19 Jun 2008
Location: United States
Online Status: Offline
Posts: 2
Quote mhuman Replybullet Topic: Distinctly Sum Fields
     Posted: 19 Jun 2008 at 6:41am

I have been working so hard to figure this out myself but try as I might, for the past three weeks straight of sleepless nights, I am still where I was before I started this journey.

 

I have researched this topic but I just simply don't know how to sum my field without getting all the duplicated values.

 

I have two tables, one is a workorder table where there is a single instance per a workorder, the other table is a cost detail table which has muliple rows per workorder.  When I bring these two tables together...you guessed it, the workorder total from the workorder table is multiplied by the number of cost detail records.

 

{GH1}CUSTOMER

wkord.wkord_no        wkord.netbill                   cstdt.scd_amount

{GH2}1038125                         

                                    466.97                                  45.85

                                    466.97                                  76.50

                                    466.97                                  96.65

 

 {GF2}                        $1,401                                   $219.00

 

{GH2}1041727

                                      354.80                                 67.20

                                      354.80                                 25.50

                                     354.80                                  32.89

 

{GF2}                           $1,064                                $125.59      

{GF1}

 

The results that I am looking for is the distinct value of netbill per workorder number so that I can get GM$ and GM% per workorder and then per customer

 I am fresh out of my CR Design I, II, III training course, I dont' know how to write "backend" statements so please keep this in mind when responding.  And also, I am close to tears so please be kind.  I can't believe that CR does not have something already in place to provide this sort of work around, it doesn't seem like a big deal but it sure can't bring things to a screeching halt when the totals are incorrect on a Quarterly Billable Summary Report!!!

 

Thanks in advance for your help!!!

IP IP Logged
hilfy
Admin Group
Admin Group
Avatar

Joined: 20 Nov 2006
Online Status: Offline
Posts: 3702
Quote hilfy Replybullet Posted: 19 Jun 2008 at 2:25pm
This is actually not all that difficult assuming that all of the records for a single work order are grouped together.
 
1.  Create a formula named "NetBill" that looks something like this:
 
If {wkord.wkord_no} = previous({wkord.wkord_no}) then
  0
else
  {wkord.netbill}
 
2.  Instead of summing {wkord.netbill} use a sum of  the new formula {@NetBill}
 
How this works is that the {@NetBill} formula will have a value for the first record of a work order (the work order number is not equal to the work order number in the previous record) - for any subsequent record for the work order, the value will be 0.  Thus, when you do a sum, you only get the value once.
 
-Dell
IP IP Logged
mhuman
Newbie
Newbie
Avatar

Joined: 19 Jun 2008
Location: United States
Online Status: Offline
Posts: 2
Quote mhuman Replybullet Posted: 20 Jun 2008 at 11:47am
thank you very much for the reply.  I will try this and see what happens...I get so confused with the duplicated fields.  I'm used to being able to write queries that will bring in the totals that I need eliminating the need to address this sort of thing.
 
Thank you!
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