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 derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Runnig Cout Of Group Elements 1

Status
Not open for further replies.

ganjass

Technical User
Dec 30, 2003
154
GB
CR10

Hi ALL.

I need to create calculations based on the number of months I have in a group. The report is always done for the last 13 months from today. The issue i have is i need to ignore the 13th month and then sum the last 3 months, the last 6 months,the last 9 months, and the last 12 months. The group section is printed per month. Is there a way i can count thr number of months in the group and assign each month a number?

Thanks in advance
 
Is the only group the month?

Where would these "calculations" be, in the report footer?

To count the number of months, you might create a formula such as:

cdate(year({table.date},month({table.date},1)

Place it in the details, right click it and select insert grand total->distinct count and then use it in whatever group or the report footer that you need.

If this doesn't satisfy your requirements, please try supplying:

Crystal version
Database used
Example data
Expected output

Rather than a text description of the environment and requirement.

-k
 
Without assigning numbers to your months, I think you could accomplish your goal by creating a series of formulas like:

//{@last12months}:
if {table.date} in dateadd("m",-13,currentdate+1) to
dateadd("m",-1,currentdate) then {table.amt}

//{@last9months}:
if {table.date} in dateadd("m",-10,currentdate+1) to
dateadd("m",-1,currentdate) then {table.amt}

Repeat for the other intervals. Then you can insert summaries on these formulas at the group and/or report levels.

If you don't want the intervals to reflect the exact date 13 months previously, but instead, based on the last 12 months preceding the current month, then change the formulas as in the following:

//{@last12months}
if {table.date} in dateadd("m",-12,currentdate + 1 - day(currentdate)) to currentdate - day(currentdate) then {table.amt}

-LB
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top