Reputation: 41
Looking for some Excel help. I have the following worksheets:
WORKSHEET WEEK1
A-------|B------|C------|D------
NAME |GAME A |GAME B |GAME C
JIM 10 15 12
BILL 12 10 5
TED
PHIL 0 8 17
WORKSHEET WEEK2
A-------|B------|C------|D------
NAME |GAME D |GAME F |GAME B
JIM 15 10 9
BILL
TED 3 21 18
PHIL 12 2 30
Basically, I'll have 10 worksheets (one per week). We are tracking people's pinball scores over a series of weeks. The games/scores will NOT be in the same order on the sheet week after week (20 machines, only six played per week).
I need to calculate Average and Median for the machine across multiple worksheets, AND eliminate any missing or zeroed scores (so the average of 10,0,10 is 10, same for median, same for data missing/null).
I used this for the first week
=MEDIAN(IF('1B'!L:L>0,'1B'!L:L))
And seemed to be just ducky, but am struggling getting this to be cross sheet in varied columns excluding blanks.
I'm not opposed to having another sheet that looks through all of the worksheets and columns to find a match on the game title and then grab that column, calculate, done. But if I have to do this manual-ish, that's totally not a problem.
I'm a C# developer, so I get code, I'm just dreadfully bad at Excel and the syntax makes me the tiniest bit sad.
UPDATE: The expected output is as follows: GAME A: Average: X, Median Y GAME B: Average: Z, Median N
Thanks much!
Upvotes: 1
Views: 1360
Reputation: 7762
Assuming that:
1) You have Excel 2007
or later
2) The data in each of the sheets to be queried occupies the range A1:D5
(with headers in row 1 and names in column A)
3) You put your choice of game (e.g. "GAME B") for which you wish to obtain the desired results in cell A1
of a sheet other than those being queried
First go to Name Manager
(Formulas
tab) and make the following definition:
Name: SheetList
Refers to: ={"Sheet1","Sheet2","Sheet3"}
(Or whatever happen to be the relevant sheet names in question.)
The required array formula**
for the average is then:
=AVERAGE(IFERROR(1/(1/N(INDIRECT(SheetList&TEXT(ROW(B2:D5)*10^5+TRANSPOSE(MODE.MULT(IF(T(INDIRECT(TRANSPOSE(SheetList)&TEXT(10^5+COLUMN(B2:D5),"!R0C00000"),0))=A1,COLUMN(B2:D5)),COLUMN(B2:D5))),"!R0C00000"),0))),""))
Replace AVERAGE
with MEDIAN
in the above to obtain the equivalent median for that game.
Regards
**Array formulas are not entered in the same way as 'standard' formulas. Instead of pressing just ENTER, you first hold down CTRL and SHIFT, and only then press ENTER. If you've done it correctly, you'll notice Excel puts curly brackets {} around the formula (though do not attempt to manually insert these yourself).
Upvotes: 0