Report Design
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Report Design
Message Icon Topic: Conditional Sums Post Reply Post New Topic
Author Message
Reporter12
Newbie
Newbie
Avatar

Joined: 17 Jun 2009
Location: United States
Online Status: Offline
Posts: 2
Quote Reporter12 Replybullet Topic: Conditional Sums
     Posted: 17 Jun 2009 at 12:13pm
< ="Content-" content="text/; charset=utf-8">< name="ProgId" content="Word.">< name="Generator" content="Microsoft Word 11">< name="Originator" content="Microsoft Word 11"><>

I am currently in the process of writing a report that displays as a simple spreadsheet.  The purpose of this report is to display invoices with a breakout of the taxable line items as well as breaking out the tax itself.  Based upon how the data is stored, I have been unable to derive a function to withdraw it in the appropriate form.  To illustrate, here are examples of the tables that I am working with

The “Customer” Table

 

Cust_ID

Tax_Code

1234

CA01

5678

CA00


The “invoice” Table

Invoice

Cust_ID

1111

1234

1112

5678

1113

1234


The “Invoice_Detail” Table

Line_Total (cur)

Tax_Flag

GL_Account

Invoice

1000

Y

5333

1111

100

N

5150

1111

60

N

3457

1111

1500

N

5276

1112

2000

N

3256

1113


As an end result, I am trying to have the data display in this format:

 

Invoice

Cust ID

Tax Code

Total Amount

Total Taxable

Total Tax

1111

1234

CA01

1160

1000

60

1112

5678

CA00

1500

0

0

1113

1234

CA01

0

0

2000

 

The Total Taxable and the Total Tax fields are the ones that are presenting the problem.  The conditions that I am trying to account for are the following:

 

-         “Total Taxable” equals the sum of all taxable line items containing a tax flag field that equals “Y” and a Tax code that does not end in “00”

-         “Tax Total” line equals the sum of all line items where GL_Account is between 3000 and 3999.

 

Does anyone have any ideas on how to code for the “Total Taxable” and “Total Tax” fields?

IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 17 Jun 2009 at 12:51pm
You can either create formula fields to sum or you can use running totals.
Basically the same concept because the running total would need a formula to indicate what to include.
Summable formula examples:
if table.taxflag="Y" and right({table.taxcode},2)<>"00" then table.taxablefield else 0
 
if {table.glaccount} in 3000 to 3999 then table.taxfield else 0
 
IP IP Logged
Reporter12
Newbie
Newbie
Avatar

Joined: 17 Jun 2009
Location: United States
Online Status: Offline
Posts: 2
Quote Reporter12 Replybullet Posted: 18 Jun 2009 at 10:27am
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 18 Jun 2009 at 10:48am

Sorry, I assumed you had done grouping on this report.

From the looks of the data you will need to group first on Invoice # only (but maybe you need a second on Customer ID???).
Assuming you only need to group on the Invoice # try:
Change all of your Running Totals (RT) to reset on group 1.
On your group footer place your Invoice#, CustomerID Tax Code, Total Amount RT, total Taxable RT, Total Tx RT.
Suppress your details and the group header.
 
or if you use the formula fields to SUM on place everything on the group header and make the sums for the group level 1.


Edited by DBlank - 18 Jun 2009 at 10:49am
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 18 Jun 2009 at 10:51am

also just for clarity your running total evaluate formulas will be:

table.taxflag="Y" and right({table.taxcode},2)<>"00"
 
and
 
{table.glaccount} in 3000 to 3999
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