0

I have a 2-column in Excel which pairs Age with a certain value:e.g.,

34 107.8
22 5
22 97
45 76.5
46 16

I need to create a table/chart/pivot which shows me the AVERAGE value per any arbitrary group. Let's say:

BRACKET   VALUE AVG
0-39      ...
40        ...
41        ...
42-60     ...
4

2 回答 2

1

Say you have the age stored in in column A and your value in column B (I assume, you place the in rows 2-19, adjust accordingly)

Store the minimum age of each bucket (0, 40, 41, 42, 60) in column D and add a really high value below the last value (e.g. 150).

Excel 2003 solution: Enter this formula in E2 and then copy it down:

=IF(SUMPRODUCT(($A2:$A19>=D2)*(A2:A19<D3)),SUMPRODUCT($B2:$B19*($A2:$A19>=D2)*(A2:A19<D3))/SUMPRODUCT(($A2:$A19>=D2)*(A2:A19<D3)),"No values")

Excel 2007+ solution: Enter this formula in E2 and copy it down:

=IFERROR(AVERAGEIFS($B:$B,$A:$A,">="&D2,$A:$A,"<"&D3),"No values")
于 2013-03-29T22:55:45.370 回答
1

If you have the "lower bound list" in D2:D10 as Peter suggests then this "array formula" in E2 will also do the job:

=AVERAGE(IF(LOOKUP($A$2:$A$19,D$2:D$10)=D2,B$2:B$19))

confirm with CTRL+SHIFT+ENTER so that curly braces like { and } appear around the formula in the formula bar......and copy down column

To get zero in place of #DIV/0! error if no values exist for that bracket change to

=LOOKUP(10^10,IF({1,0},0,AVERAGE(IF(LOOKUP($A$2:$A$19,D$2:D$10)=D2,B$2:B$19))))

于 2013-03-30T00:21:22.237 回答