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

Conditional selection of group to total/count

Status
Not open for further replies.

suemon

IS-IT--Management
Apr 8, 2005
30
GB
I am writing a report that summarizes total number of customer visits per year then averaging the number of visits per month. This is all simple but I need to change the 'averaging' for the current year to divide by number of months passed rather than the simple /12.
Making the divide by a dynamic figure to give me a month average is fine. My problem is being able to total those dates starting only with 2008. Can anyone help?
 
You should probably be in forum149 or forum767. Anyway, you can use a denominator like this, assuming you would evaluate through the last full month:

datediff("m",date(year(currentdate),1,1),maximum(lastfullmonth))+1

To conditionally total those records within the current calendar year, you could use a formula like this:

//{@incurrentyear}:
if {table.date} in date(year(currentdate),1,1) to maximum(lastfullmonth) then
{table.visit}

Then you can use:

sum({@incurrentyear})/(datediff("m",date(year(currentdate),1,1),maximum(lastfullmonth))+1)

-LB
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top