Sum Product to average values with criteria across rows and columns

CarolynS

Board Regular
Joined
Oct 27, 2015
Messages
56
I have spreadsheet of data that is set up as follows (I haven't populated the whole table with scores but hopefully you get the idea):


Area
Score Type
Subject 1
Subject 1
Subject 1
Subject 2
Subject 2
Subject 3
Subject 3
A
Learner
4.5
3
2
4
1
5
A
LM
3.2
4
2
4
2.5
3
1.5
A
Average
3.9
3.5
2
4
1.8
4
0.8
B
Learner
B
LM
B
Average
C
Learner
C
LM
C
Average

<tbody>
</tbody>


The data set is much bigger in real life. I need to find the average scores by area, score type and subject i.e. average if area =a score type = learner and subject = subject 1

I have tried using arrays but got the error "Excel ran out of resources while attmempting to calculate one or more formulas. As a result, these formulas cannot be evaluated".

I have therefore been trying to use sum product but just can't work out how to write the formula. I am also still getting the above error which is making it hard to know if I'm along the right lines with the sumproduct formula (as I can't see if it is calculating correctly). If I can get the formula right I think I can then break the formula down in to bits and put these helper cells to avoid getting the error? Or is there a better way of working out the averages?

Any help would be greatly appreciated

Thanks
 

Excel Facts

Formula for Yesterday
Name Manager, New Name. Yesterday =TODAY()-1. OK. Then, use =YESTERDAY in any cell. Tomorrow could be =TODAY()+1.
Maybe...


A
B
C
D
E
F
G
H
I
J
K
L
M
N
1
Area​
Score Type​
Subject 1​
Subject 1​
Subject 1​
Subject 2​
Subject 2​
Subject 3​
Subject 3​
Area​
Score Type​
Subject​
Result​
2
A​
Learner​
4,5​
3​
2​
4​
1​
5​
A​
Learner​
Subject 1​
3,167​
3
A​
LM​
3,2​
4​
2​
4​
2,5​
3​
1,5​
A​
LM​
Subject 2​
3,250​
4
A​
Average​
3,9​
3,5​
2​
4​
1,8​
4​
0,8​
A​
Average​
Subject 3​
2,400​
5
B​
Learner​
6
B​
LM​
7
B​
Average​
8
C​
Learner​
9
C​
LM​
10
C​
Average​
11

Criteria in columns K:M

Array formula in N2 copied down
=AVERAGEIF(C$1:I$1,M2,INDEX(C$2:I$10,MATCH(1,IF(A$2:A$10=K2,IF(B$2:B$10=L2,1)),0),0))
Ctrl+Shift+Enter

Hope this helps

M.
 
Upvote 0
HI Marcelo

Thanks for your response. Sorry for the delay in replying. I had tried to use an array but that was what was causing the error. I can't remember the exact formula I used so will give this one a go and see if there's any change

Thanks
 
Upvote 0
Hi Marcelo

So, I tried your formula and I'm not getting an errors any more, however I don't seem to be getting the right answers either. The formula I'm using (as an array):

=AVERAGEIF('Diagnostic Raw Data'!$S$1:$BR$1,B$40,INDEX('Diagnostic Raw Data'!$S$1:$BR$6412,MATCH(1,IF('Diagnostic Raw Data'!$P2:$P6414=$A42,IF('Diagnostic Raw Data'!$R$1:$R$6413="Learner Score",1)),0),0))

where:

'Diagnostic Raw Data'!$S$1:$BR$1 is the subject headings in my raw data set

B$40 is the subject heading criteria

'Diagnostic Raw Data'!$S$1:$BR$6412 is the range in my raw data containing the scores I'm trying to calculate

'Diagnostic Raw Data'!$P2:$P6414 is the criteria range in my raw data containing the area name

$A42 is the criteria for the area name

'Diagnostic Raw Data'!$R$1:$R$6413 is the criteria range in my raw data containing the score type

="Learner Score" is obviously the criteria for the score type

My criteria are laid out slightly differently to yours for my calculations. I'm just looking at learner score at the moment and my table is as below (but I can't see that this should cause an issue?). I am getting values populated in it but when I double check the calculations manually, the answers the formula is giving are wrong :(

Does it look like I've gone wrong somewhere?

Thanks

Subject 1Subject 2Subject 3Subject 4
Area Aarray formulaarray formulaarray formulaarray formula
Area Barray formulaarray formulaarray formulaarray formula
Area Carray formulaarray formulaarray formulaarray formula

<tbody>
</tbody>
 
Upvote 0
I have found a solution using Sumproduct instead of an array where (using the example in my opening post) the following formula works in N2:

=SUMPRODUCT(C2:I10*(A2:A10=K2)*(C1:I1=M2)*(B2:B10=L2))/SUMPRODUCT((C2:I10<>"")*(A2:A10=K2)*(C1:I1=M2)*(B2:B10=L2))
 
Upvote 0

Forum statistics

Threads
1,215,032
Messages
6,122,772
Members
449,095
Latest member
m_smith_solihull

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top