Finding the average across multiple sheets

Q

quailhunter

I'm trying to find the average for a person with scores in column 4 on
separate sheets. The following function returns #VALUE.. What am I doin
wrong? Because the person may be in a different row on each sheet, I'
thinking I need to use the VLOOKUP function.... Help!!! Also, as a
aside, the person may have a zero on one sheet that would affect th
average score...

=AVERAGE(VLOOKUP(A4,Week03:Week01!A$4:G$30,4,0)
 
Q

quailhunter

Hi Biff,
Yes. If they have a zero, then this should not count in their averag
score.

Thanks.
 
B

Biff

Hi!

After reading your post again I see that the name and score can be anywhere
within the range on each of the sheets. I don't think this is possible to do
(at least, I don't know how to do it!).

If the data was in the same cell on each sheet this would be simple but a
multi-conditional (name and score greater than zero)average across sheets is
not possible! Excel just doesn't handle 3D referencing easily. If anyone CAN
do this I be interested to see how! (using a single formula!)

Biff

"quailhunter" <[email protected]>
wrote in message
 
H

Harlan Grove

quailhunter wrote...
I'm trying to find the average for a person with scores in column 4 on 3
separate sheets. The following function returns #VALUE.. What am I doing
wrong? Because the person may be in a different row on each sheet, I'm
thinking I need to use the VLOOKUP function.... Help!!! Also, as an
aside, the person may have a zero on one sheet that would affect the
average score...

=AVERAGE(VLOOKUP(A4,Week03:Week01!A$4:G$30,4,0))

If you're using VLOOKUP, there'd be at most only one match for A4 in
any of the worksheets' A4:A30 ranges? If so, you'd need a list of the
worksheet names in some range (I'll refer to it as WSL), then you could
try

=SUMPRODUCT(SUMIF(INDIRECT("'"&WSL&"'!A4:A30"),A4,INDIRECT("'"&WSL&"'!D4:D30")))
/SUMPRODUCT(--(SUMIF(INDIRECT("'"&WSL&"'!A4:A30"),A4,INDIRECT("'"&WSL&"'!D4:D30"))>0))
 
B

Biff

That doesn't work for me.

SUMPRODUCT(--(SUMIF(INDIRECT("'"&WSL&"'!A4:A30"),A4,INDIRECT("'"&WSL&"'!D4:D30"))>0))

Returns the incorrect count

Biff
 
A

Aladin Akyurek

D
That doesn't work for me.

SUMPRODUCT(--(SUMIF(INDIRECT("'"&WSL&"'!A4:A30"),A4,INDIRECT("'"&WSL&"'!D4:D30"))>0))

Returns the incorrect count
[...]

Do you have negative numbers in the ranges of interest?
 
H

Harlan Grove

Aladin Akyurek wrote...
....
Do you have negative numbers in the ranges of interest?

Interesting point. As I've written before, if there can be valid
positive and negative values, there can also be valid zero values. If
there can be valid zero values, you can't ignore all zeros in averages.

That said, if all the values were positive *and* there were only one
entry matching A1 in each other worksheets' A3:A30 range, then this
should work (at least it works in my tests).
 
B

Biff

Do you have negative numbers in the ranges of interest?

No negatives.

The second Sumproduct is only counting a single instance where the value is
0 per sheet:

Sheet2

Sue....... 34
Joe........ 34
Bob....... 93
Jim........ 26
Joe....... 100
Tom...... 82

Sheet3

Tom....... 7
Sue........ 9
Liz........ 88
Joe........ 0
Joe....... 93
Bob...... 66

=SUMPRODUCT(--(SUMIF(INDIRECT("'"&wsl&"'!A4:A30"),A4,INDIRECT("'"&wsl&"'!D4:D30"))>0))

Returns 2

Biff

Aladin Akyurek said:
D
That doesn't work for me.

SUMPRODUCT(--(SUMIF(INDIRECT("'"&WSL&"'!A4:A30"),A4,INDIRECT("'"&WSL&"'!D4:D30"))>0))

Returns the incorrect count
[...]

Do you have negative numbers in the ranges of interest?
 
B

Biff

That said, if all the values were positive *and* there were only one
entry matching A1 in each other worksheets' A3:A30 range, then this
should work (at least it works in my tests).

Yes, it works under those conditions, where there is only a single instance
(or none) per sheet. I was working on a solution in which there were
multiple instances per sheet. How could that be done? Nothing I've tried
works. The difficult part is the count.

Biff
 
H

Harlan Grove

Biff wrote...
Yes, it works under those conditions, where there is only a single instance
(or none) per sheet. I was working on a solution in which there were
multiple instances per sheet. How could that be done? Nothing I've tried
works. The difficult part is the count.
....

There are times it's a PITA that Excel really isn't a 3D spreadsheet.

The simplest solution would be using Laurent Longre's MOREFUNC.XLL
add-in, specifically, using that add-in's THREED function.

=SUMPRODUCT(--(THREED(A:Z!$A$4:$A$30)=A4),THREED(A:Z!$D$4:$D$30))
/SUMPRODUCT((THREED(A:Z!$A$4:$A$30)=A4)*(THREED(A:Z!$D$4:$D$30)>0))

Using only built-in functions, it gets very ugly, but it's possible. If
WSL, the named list of worksheets to process, were a horizontal array,

=SUMPRODUCT(
--(T(OFFSET(INDIRECT("'"&WSL&"'!A4:A30"),ROW(INDIRECT("4:30"))-4,0,1,1))=A4),
N(OFFSET(INDIRECT("'"&WSL&"'!D4:D30"),ROW(INDIRECT("4:30"))-4,0,1,1))
)/SUMPRODUCT(
(T(OFFSET(INDIRECT("'"&WSL&"'!A4:A30"),ROW(INDIRECT("4:30"))-4,0,1,1))=A4)*
(N(OFFSET(INDIRECT("'"&WSL&"'!D4:D30"),ROW(INDIRECT("4:30"))-4,0,1,1))>0)
)
 
B

Biff

Using only built-in functions, it gets very ugly

It's not all that ugly and it works! Very nice!

I was headed in the right direction but was still a long ways off.

Wonder how the OP made out?

Biff
 
Q

quailhunter

Guys... I feel like you're both pouring your guts out on this one, but
I'm definitely doing something wrong. When I entered Biff's function, I
get #NAME? returned...

Here's my setup:
Sheet1 ---> (This is where I'd like to store the average of sheet2 &
sheet3 for each person on Sheet1...)
Bob
Jim
Joe
Joex
Liz
Sue
Tom

Sheet2...
Bob 93
Jim 26
Joe 34
Joe 100
Sue 34
Tom 82

Sheet3...
Bob 66
Joe 0
Joex 93
Liz 88
Sue 9
Tom 7

So in Sheet1, in B4, I inserted Biff's function and get #NAME
returned....
 
B

Biff

Hi!

For what it's worth.......

Some of the "biggest hitters" there are have replied to this thread. If they
can't do it, it can't be done!

At least one of the formulas offered here should work so I'm guessing that
you're missing some minor detail.

If you want to send me a copy of your file I'll take a look. Just let me
know how to contact you.

Biff

"quailhunter" <[email protected]>
wrote in message
 
H

Harlan Grove

"quailhunter" <[email protected]>
wrote...
....
Here's my setup:
Sheet1 ---> (This is where I'd like to store the average of sheet2 &
sheet3 for each person on Sheet1...)
Bob
Jim
Joe
Joex
Liz
Sue
Tom

Sheet2...
Bob 93
Jim 26
Joe 34
Joe 100
Sue 34
Tom 82

Sheet3...
Bob 66
Joe 0
Joex 93
Liz 88
Sue 9
Tom 7

So in Sheet1, in B4, I inserted Biff's function and get #NAME
returned....
....

What's the *EXACT* formula you're trying?

If you're using something like

=SUMPRODUCT(
--(T(OFFSET(INDIRECT("'"&WSL&"'!A4:A30"),ROW(INDIRECT("4:30"))-4,0,1,1))=A4)
,
N(OFFSET(INDIRECT("'"&WSL&"'!D4:D30"),ROW(INDIRECT("4:30"))-4,0,1,1))
)/SUMPRODUCT(
(T(OFFSET(INDIRECT("'"&WSL&"'!A4:A30"),ROW(INDIRECT("4:30"))-4,0,1,1))=A4)*
(N(OFFSET(INDIRECT("'"&WSL&"'!D4:D30"),ROW(INDIRECT("4:30"))-4,0,1,1))>0)
)

did you create a list of worksheet names and define the name WSL referring
to that list? If not, that'd explain the #NAME? error. If I define WSL
referring to

={"Sheet2","Sheet3"}

and put your sample names in col A and sample numbers in col D beginning in
row 4, then with Bob in cell A4 in Sheet1 and the other names below it, I
enter the *array* formula above in cell B4 in Sheet1, then fill it down into
B5:B10, I get the following results in A4:B10.

Bob 79.5
Jim 26
Joe 67
Joex 93
Liz 88
Sue 21.5
Tom 44.5
 
F

Fin Fang Foom

Hi Harlan Grove,

When you get a chance. Can You explain step by step how this formul
works*?*


SUMPRODUCT((T(OFFSET(INDIRECT("'"&WSL&"'!A4:A30"),ROW(INDIRE
T("4:30"))-4,0,1,1))=A4)*(N(OFFSET(INDIRECT("'"&WSL&"'!D4:D30),ROWINDIRE
T("4:30"))-4,0,1,1))>0
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top