Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Subtracting a total only in a certain month

Status
Not open for further replies.

QueSpr04

Programmer
Jun 3, 2004
50
US
CR 10
ODBC[RDO} connection

How can I get a formula to subtract a total from another field only when it is a certain month. That month being October. For instance if a have a total from one formula that is 12,000, and the other field is 1,200, I want 1,200 to be subtracted from 12,000 only in the month of October. Please Help!
 
Create a formula that checks the month and only subtracts the other formula if month is 10.

Code:
if month({table.date}) = 10 then
    {@formula1} - {@formula2}
else
    {@formula1}

Of course, you need to substitute you fields.
If you want the current month, substitute {table.date} with CurrentDate.

~Brian
 
How was this total created? Do you mean when the month the report is ran is October, or a date field is October?

Posting technical information generally helps:

Crystal version
Database/connectivity used
Example data
Expected output

You were kind enough to post some of this critical information.

One method is to create a formula which will use an IF statement:

If month({table.field}) = 10 then
sum({table.field1})-sum({table.field2})
else
sum({table.field1})

If you're using a Running Total, use the evaluate->Use a formula to allow for this.

If this doesn't get you there, please provide your environment and more descriptive information.

-k
 
Thanks bdreed35. That formula worked perfectly.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top