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

Conditional average

Status
Not open for further replies.

nugget5

Programmer
Feb 1, 2007
8
US
My datasource brings back a row showing a monthly summary for each user for the last 12 months. I am trying to get an average of the Number of Days Worked for the current month. Here is my formula:

whileprintingrecords;
average({ds.daysworked}, {ds.WorkMonth}, Month (CurrentDate))

I know this is not the correct way to utilize the
average(fld, condfld, cond) function, but I am unable to find a solution to this problem. I have also tried running totals to solve this, however I need this average figure in the group footer (grouped by user).
 
So for every user, you're going to have the same average of days worked number for all users?

You shouod post example data and required output as a description just brings up questions.

Why not create an outer group on the month and do the summary on it:

average({ds.daysworked}, {ds.WorkMonth})

You can set it to a variable if need be in the group header and reference the variable.

-k
 
Here is an example of the data from my datasource:

user year month days netcash amt amt days
id wrked wrked wrked var over short inbal
----- ------ ----- ----- ------- ------ -------- -----
Admin 2007 2 4 -506.00 3.00 -509.00 1
Admin 2007 1 2 40.00 40.00 .00 1
Admin 2006 12 1 .00 .00 .00 1
Admin 2006 11 3 .00 .00 .00 3
Admin 2006 10 0 .00 .00 .00 0
Admin 2006 9 2 -40.00 .00 -40.00 1
Admin 2006 8 1 -500.00 .00 -500.00 0
Admin 2006 7 2 -.0100 .00 -.01 1
Admin 2006 6 4 -43.16 .00 -43.16 2
Admin 2006 5 0 .00 .00 .00 0
Admin 2006 4 2 .00 .00 .00 2
Admin 2006 3 2 .44 .44 .00 0
USER5 2007 2 0 .00 .00 .00 0
USER5 2007 1 2 500.00 500.00 .00 1
USER5 2006 12 2 .00 50.00 -50.00 0
USER5 2006 11 0 .00 .00 .00 0
USER5 2006 10 0 .00 .00 .00 0
USER5 2006 9 0 .00 .00 .00 0
USER5 2006 8 0 .00 .00 .00 0
USER5 2006 7 0 .00 .00 .00 0
USER5 2006 6 0 .00 .00 .00 0
USER5 2006 5 0 .00 .00 .00 0
USER5 2006 4 0 .00 .00 .00 0
USER5 2006 3 0 .00 .00 .00 0

The output should be
Admin
Feb 07 4 (506.00) 3.00 (509.00) 1
Jan 07...
Dec 06...
...
Mar 06...

Cur Mnth 4 (506.00) 3.00 (509.00) 1
Avg User ?? ?? ?? ?? ??

YTD 6 (466.00) 43.00 (509.00) 2
Avg User ?? ?? ?? ?? ??


USER5
Feb 07 4 (506.00) 3.00 (509.00) 1
Jan 07...
Dec 06...
...
Mar 06...

Cur Mnth 4 (506.00) 3.00 (509.00) 1
Avg User ?? ?? ?? ?? ??

YTD 6 (466.00) 43.00 (509.00) 2
Avg User ?? ?? ?? ?? ??


The problem is that the average is based on the work of all users. Does this clear it up?


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top