Crystal Reports last twelve months

5 pts.
Tags:
Crystal Reports
SQL Database
SQL queries
I wrote a report that accululates invoice totals for each customer in a sql database based on period and year for period. I manually entered the last 11 months in the formulas by taking current month minus 1, then current month plus 10, year minus one and so forth. How can I make this process automatic.

Answer Wiki

Thanks. We'll let you know when a new response is added.

A simple way in Crystal, I am assuming that the report date is restricted to a single full year, then:

Make a formula extracting the month from the date field – MONTH(Subtotal)

Then make a formula for each month – if {@Month} = 1 then {Subtotal} else 0 – do this for each month.

Alternative if you have an open date on the report, no overall date restriction and your SQL is a DateTime field use:

if {DocDate] in DateTime (200, 01, 01, 00, 00, 00) to DateTime (2009, 01, 31, 00, 00, 00) then {Subtotal}.

If is is a date field use:

if {DocDate] in Date (200, 01, 01) to Date (2009, 01, 31) then {Subtotal}.

Please these calculated fields in the Details section. Then create a Group for the Customers and you can sum the invoices to the Group (Customer) and hide the details.

This method requires all of the data to be pulled into Crystal. If you can create a view on the SQL server to sum the records by Customer or Sales region it is much quicker to only pull the sums in to the Crystal report.

These are simple solutions, but will require an annual update on the formulas, option one on the overall date restriction, option two on each of the monthly formulas.

Hope this helps.

Discuss This Question:  

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following