Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: summarizing one to many relationships Post Reply Post New Topic
Author Message
jonculp
Newbie
Newbie
Avatar

Joined: 29 Oct 2009
Location: United States
Online Status: Offline
Posts: 2
Quote jonculp Replybullet Topic: summarizing one to many relationships
     Posted: 29 Oct 2009 at 10:28am
Not exactly sure if this is a technical, DB link, or report issue... Confused

I'm new to Crystal Reports.  I'll try to summarize the issues the best that I can.  Here are some facts:

Version: Crystal Reports 2008
DB Connection: SQL Server - ODBC
Table 1: Account Data
Table 2: Payment Data
Table 3: Charge Data

Table 1 is linked with "Left Outer Joins" to table 2 and 3 by account number.

Sample Data Fields:
Table 1 (Account)
Acct#   Acct_Bal   Portfolio
1001    $1,000         A
1002    $1,500         A
1003    $1,200         B

Table 2  (Payments)

Acct#  Pay_Amnt   Pay_Dt
1002      $5           01/05/09
1002      $10         02/01/09
1003      $5           01/01/09
1003      $10         02/01/09
1003      $1           03/05/09

Table 3  (Charges)
Acct#  Charge_Amnt   Charge_Dt
1001        $10             01/01/09
1001        $15             02/01/09
1001        $5               03/04/09
1002        $10             02/07/09
1003        $10             02/01/09
1003        $5               04/01/09
1003        $7               04/05/09

The report would show something like:
Acct#   Acct_Bal   Portfolio   Pay_Amnt   Pay_Dt   Charge_Amnt   Charge_Dt
1001    $1,000          A              $0                0             $10             01/01/09
1001    $1,000          A              $0                0             $15             02/01/09
1001    $1,000          A              $0                0             $5               03/04/09
1002    $1,500          A              $5          01/05/09      $10             02/07/09
1002    $1,500          A              $10        02/01/09      $10             02/07/09
1003    $1,200          B              $5          01/01/09      $10             02/01/09
1003    $1,200          B              $10        02/01/09      $5               04/01/09
1003    $1,200          B              $1          03/05/09      $7               04/05/09


If I were to group this data by portfolio I would get:

Portfolio   Distinct_Acct_#s     Ttl_Bal    Ttl_Paymnts    Ttl_Charges
  A                     2                   $6,000           $15                $50
  B                     1                   $3,600           $16                $12
*items in bold are returning incorrect data

Example Formulas would return:
if {account.portfolio} = "A"
and {charge.chargdate} in "02/01/09" to "02/28/09
then {charge.chargeamnt}

If I then summed this formula and placed it in the report footer it would return $35 instead of the correct amount of $25.

CryDead
Dead
Conclusion:
I understand how/why it creates multiple records per account on the report level, and why it is repeating data, but I can not find an obvious way around this, if there is one.  I am unsure whether the problems I am having are due to the way I am connecting our data, or the way I am trying to summarize the data.  I wish to group the data and also create similar summary formulas similar to the examples I gave above.  Any insight or recommendation would be hugely appreciated. Star

I will become one with the data.
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 29 Oct 2009 at 12:01pm
My two cents on the usually ways of handling duplicate data rows:
1. Massage the data on the backend (pre crystal) using views or Stored procedures so that it does not give you dupes or does all the calculations in it.
2. Use subreports (can be a pain and drain your resources but sometimes all you can use)
3. Use varaible formulas to conditianally include rows in your calcualtions. Tons of postings about these all over this site
4. Use Running Totals to do the same thing as option #3. Tons of posting on these as well.
You can ask more specific questions once you choose a route.
 
HTH


Edited by DBlank - 29 Oct 2009 at 12:01pm
IP IP Logged
jonculp
Newbie
Newbie
Avatar

Joined: 29 Oct 2009
Location: United States
Online Status: Offline
Posts: 2
Quote jonculp Replybullet Posted: 29 Oct 2009 at 12:18pm
I tried option 1 by creating some summary tables in access of the payments and charges tables but this limits me from using some of the data fields.  My actual table has 4 or 5 different status/transactional fields that tell me more about the payment/charge and I just don't see how I could summarize it... yet.

After posting I did come across a few sub-report topics that I am going to try, which sound like they will give me similar data to the summary tables, but they will be live(?). I also think variable formulas might do the trick as well...  I was just hoping there was some obvious way around this that I overlooked that would solve the duplicate problem for me LOL, but as usual with programming, you can't expect it to just know what you want.


Edited by jonculp - 29 Oct 2009 at 12:39pm
I will become one with the data.
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