开发者

Calculating a weighted average for a group

I have a reports similar to the following:

Calculating a weighted average for a group

I need it to look like the following:

Calculating a weighted average for a group

The report is 开发者_如何学编程grouped by Department. I cannot figure out how to create the formula field YTD AVG to calculate and show in each group footing and then reset for the next group.

I understand the calculation for the YTD AVG, for example YTD AVG for dept1 would be:

((80*100)+(100*40)) / (100+40)

I just don't know how to get it in Crystal Reports.


Use Crystal's weighted average summary function:

  1. Insert a summary, and select the group footer
  2. Select the database field containing the average
  3. Select Weighted average with
  4. Select the field containing the number of responses


Create a formula called 'Month_Total' and place it in the details section for each row/month and suppress it {month.average} * {month.responses} In your example, this will give you the "(80*100)" and "(100*40)" portions.

Create another formula called 'Department_Avg' and place it in the department group footer section sum({@Month_Total},{month.month_name}) / sum({month.responses},{month.month_name})

The second parameter to Sum() should match whatever department-related field you're already grouping on and specifies that you want to sum only over the individual groups. This will give you your entire YTD calculation for each group/department.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜