Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Two Way Lookup using sumproduct

Status
Not open for further replies.

arvarr

MIS
Nov 24, 2009
260
AU
Hi
Was wondering if someone can help out with formula.

What I'm trying to achieve is a two way lookup.
Example: I need to find out the value when the criteria is North in Column A and West in Row 1.

The formula below gives me the total.
It's great if all records are unique but is there a way of finding out the separate values. The separate values are 2 and 7. The sumproduct formula gives me 9.


A B C D
Mail West West
North 1 2 7
East 2 4 5
South 3 6 3
West 4 8 1

West
North =SUMPRODUCT((A2:A5=A8)*(B1:D1=B7)*(B2:D5))

Thanks.
Kind Regards,
arvarr
 



Hi,

That's because SUMPRODUCT is not a lookup function. It is an aggregation function.

Your example and formula are not consistent, and consequently jiberish!!! Please post clear and consistent information.

Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
Hi Skip
So, is there any way that I can look use a two way lookup?
Thanks.
 
Hi Skip
What's the ideal formula for a two way lookup?
Yes, the above is just an example and it clearly shows me result to expect.


Mail West West
North 1 2 7
East 2 4 5
South 3 6 3
West 4 8 1

Thanks.
 



Please explain EXACTLY what you want. I need lookup values consisten with the example data and the expected results.

Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
Data as follows:

Mail West West
North 1 2 7
East 2 4 5
South 3 6 3
West 4 8 1

Lookup Value = North (Column A)
Lookup Value = West (Row 1)

The answer would be 2 and 7.

Thanks.
 



The OFFSET function.

This function has 5 arguments and it returns a range.

Arg 1 would be A1

Arg 2 & 3 are the row & column offsets respectively. The row offset would be a MATCH lookup on column A. The column offset would be a MATCH lookup on row 1.

Args 4 7 5 are the row & column range counts respectively. The row count is the count of NORTH in column a using COUNTIF and the column count is the count of WEST in row 1 using COUNTIF.

Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
Would you be able to give an example of how the offset formula will return the answer 2 and 7?
Thanks
 



It returns a RANGE.

Then you use that range in the INDEX function to return a value within the range.

Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 



Assuming that G1 contains North and H1 contains West and F2 & F3 contain 1 & 2...
[tt]
G2: =INDEX(OFFSET($A$1,MATCH($G$1,$A$2:$A$5,0),MATCH($H$1,$B$1:$D$1,0),COUNTIF($A$2:$A$5,$G$1),COUNTIF($B$1:$D$1,$H$1)),F2)
[/tt]
and copy to G3

Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top