Index Match

BWMagee

Board Regular
Joined
Feb 18, 2014
Messages
112
Hi, I am using the INDEX, MATCH combination with a number of criteria, but am receiving an incorrect result.

In plain english, here is what I am trying to do.

The formula is entered into "Sheet2" column D.
The value I wish to return is an average of "Sheet1" column Q.
Based on the following criteria:
a) The value in "Sheet2" column A, is found in "Sheet1" column L
b) The value in "Sheet2" column B, is found in "Sheet1" column M
c) The value in "Sheet1" column H, is one of the 5 highest values in that column

I've tried a number of variations without success, but here is the latest formula used:

<style type="text/css">p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px 'Lucida Grande'; color: #000000}span.s1 {color: #006107}span.s2 {color: #ab30d6}span.s3 {color: #a54a29}span.s4 {color: #0057d6}span.s5 {color: #33af4a}span.s6 {color: #ff9c1b}</style>{=AVERAGE(INDEX('Sheet1'!Q:Q,MATCH(1,('Sheet1'!L:L='Sheet2'!A:A)*('Sheet1'!M:M1='Sheet2'!B:B)*(('Sheet1'!H:H>=MAX('Sheet1'!H:H)-5)),0)))}

This returns an answer of '48'.
'48' is the first value in "Sheet1" column Q that meets the three criteria (a, b, c). However, it is not the average. The average should be 40.2 =(48+49+35+45+24)/5.
There are many more values than those in column Q. But those are the 5 that meet the three criteria.

Any help is much appreciated!
 

Excel Facts

Links? Where??
If Excel says you have links but you can't find them, go to Formulas, Name Manager. Look for old links to dead workbooks & delete.
Re: Index Match Help

the basic INDEX/MATCH will return the 1st it finds, then stop looking.

I think what you need is AVERAGEIFS(), however, Im not sure I understand why you are looking for a range in another range?
=averageifs(range-to-average, criteria1-range, criteria1, criteria2-range, criteria2, criteria3-range, criteria3, ..............)
 
Upvote 0
Re: Index Match Help

the basic INDEX/MATCH will return the 1st it finds, then stop looking.

I think what you need is AVERAGEIFS(), however, Im not sure I understand why you are looking for a range in another range?
=averageifs(range-to-average, criteria1-range, criteria1, criteria2-range, criteria2, criteria3-range, criteria3, ..............)

Thanks very much. I have adapted it as such:

<style type="text/css">p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px 'Lucida Grande'; color: #000000}span.s1 {color: #0057d6}span.s2 {color: #006107}</style>=AVERAGEIFS('Sheet1'!Q:Q,'Sheet1'!L:L,'Sheet2'!A6,'Sheet1'!H:H,LARGE('Sheet1'!H:H,{1,2,3,4,5}))

First you will see a few changes:
*Now using the AVERAGEIFS formula. Have eliminated the M:M criteria (for now). And changed the MAX function to a LARGE function.

This yields me the result '24', which as you can see from my first post, is the lowest of the five values. But I am after the average, not the lowest, so I'm still doing something wrong. If I change the LARGE function to {1} only, (which represents the highest value in the columns I am searching H:H) it yields the value '24'. If I change to {5} only it yields a value of '48' (which represents the 5th highest value in column H:H). If I change to {3} only, it yields '35' (which represents the 3rd highest value in H:H).

What this means is that the LARGE function is finding the correct values. But for some reason, they are not being averaged together. I wonder what the problem is?
 
Upvote 0
Re: Index Match Help

Maybe you can adjust the example below to meet your needs.
This is an array formula that must be entered with CTRL-SHIFT-ENTER.
Excel Workbook
ABCDEF
1a1t121a
2a2t137t1
3d3y894
4f4t1678.8
5a5r59
6g6r89
7a7t170
8f8r91
9a9t175
10a10t124
11t11t199
12a12t169
13a13t353
14a14t186
Sheet
 
Upvote 0
Re: Index Match Help

Can you provide some sample data and what the expected outcome is?

Sheet2

AI
6Centre=FORMULA

<tbody>
</tbody>

Sheet1

HLQ
8
6Centre48
94Office27
108Centre49
117Centre45
125Centre35
133Hotel38
149Centre24
152Office21
161Centre26

<tbody>
</tbody>

The value I'm looking to return is from Sheet1 ColumnQ.
It is the average of numbers in that column, when:
a) Sheet1 ColumnL = Sheet2 ColumnA, Row6 [ie. "Centre" - L8, L10, L11, L12, L14, L16]
b) The values in Sheet1 ColumnH are the five highest in that column [ie. 9,8,7,6,5 - H8, H10, H11, H12, H14]

Therefore it should be reading from the following rows in Sheet2:
8, 10, 11, 12, 14
Therefore the values in Q it should be averaging are:
48, 49, 45, 35, 24
= 40.2

Thanks!
 
Upvote 0
Re: Index Match Help


<colgroup><col style="width:30px; "><col style="width:64px;"><col style="width:64px;"><col style="width:64px;"><col style="width:64px;"><col style="width:64px;"><col style="width:64px;"></colgroup><tbody></tbody>

Spreadsheet Formulas
CellFormula
F4{=SUMPRODUCT(--($D$1:$D$10000=LARGE(IF(A1:A10000=F1,IF(C1:C10000=F2,D1:D10000)),{1,2,3,4,5}))*(B1:B10000))/5}

<tbody>
</tbody>
Formula Array:
Produce enclosing
{ } by entering
formula with CTRL+SHIFT+ENTER!

<tbody>
</tbody>

Thanks for the reply. It returns a message 'this formula contains an error' and highlights my equivalent to the F1 value in your example.

<style type="text/css">p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px 'Lucida Grande'; color: #000000}</style>{=SUMPRODUCT(--('Sheet1'!H8:H16=LARGE(IF('Sheet1'!L8:L16='Sheet2'!A6)),{1,2,3,4,5}))*('Sheet1'!Q8:Q116))/5}
 
Upvote 0
Re: Index Match Help

See below.

Excel Workbook
ABI
6Centre40.2
Sheet2
Excel Workbook
HKLQ
86Centre48
94Office27
108Centre49
117Centre45
125Centre35
133Hotel38
149Centre24
152Office21
161Centre26
Sheet1
 
Upvote 0
Re: Index Match Help

Spreadsheet Formulas
CellFormula
I6{=SUMPRODUCT(--(Sheet1!$H$8:$H$16=LARGE(IF(Sheet1!$L$8:$L$16=Sheet2!$A$6,Sheet1!$H$8:$H$16),{1,2,3,4,5}))*Sheet1!$Q$8:$Q$16)/5}

<tbody>
</tbody>
Formula Array:
Produce enclosing
{ } by entering
formula with CTRL+SHIFT+ENTER!

<tbody>
</tbody>

Works perfectly, thanks!
 
Upvote 0

Forum statistics

Threads
1,215,611
Messages
6,125,829
Members
449,266
Latest member
davinroach

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