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!

Sales by Month Bar Chart - Last 12 Months 2

Status
Not open for further replies.

mwake

Programmer
Feb 12, 2004
151
US
I'm using Crystal Reports 2008 and the data source is an Oracle db. I want to create a sales by month bar chart that captures the current month's sales and the previous 11 months. IS there any way to get the chart to roll over automatically when the month changes?? The only thing I can think of is to create a formula for each month that extracts the current month from the current date, then subtracts months to get prior month numbers. Any ideas on how to make this work??
 
I would use dateserial(), as in:

//{@month}:
if {table.date} in dateserial(year(currentdate),month(currentdate),1) to currentdate then
totext(dateserial(year(currentdate),month(currentdate),1),"MMMM yyyy") else //this month
if {table.date} in dateserial(year(currentdate),month(currentdate)-1,1) to dateserial(year(currentdate),month(currentdate),1)-1 then
totext(dateserial(year(currentdate),month(currentdate)-1,1),"MMMM yyyy") else //last month
if {table.date} in dateserial(year(currentdate),month(currentdate)-2,1) to
dateserial(year(currentdate),month(currentdate)-1,1)-1 then
totext(dateserial(year(currentdate),month(currentdate)-2,1),"MMMM yyyy") else //two months ago
//etc.

You can use this as your on change of field in the chart.

-LB
 
Thanks LB. That worked perfectly!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top