Two way lookup (Sumproduct or other faster way)

snjpverma

Well-known Member
Joined
Oct 2, 2008
Messages
1,584
Office Version
  1. 365
Platform
  1. Windows
Source Data

ABC
1EmployeeItem code.Items Sold
2A180
3B190
4
5A2110
6B2120
7

<tbody>
</tbody>


Output

FGH
112
2A80110
3B90120
4C

<tbody>
</tbody>

Spreadsheet Formulas
CellFormula
G2=SUMPRODUCT(($A$2:$A$7=$F2)*($B$2:$B$7=G$1)*$C$2:$C$7)
H2=SUMPRODUCT(($A$2:$A$7=$F2)*($B$2:$B$7=H$1)*$C$2:$C$7)

<tbody>
</tbody>

<tbody>
</tbody>

Excel tables to the web >> Excel Jeanie HTML 4

I have used sumproduct function to get the number of items sold in G2 and H2. I would like to know if there is a faster way to do it? The sumproduct makes my worksheet quite slow as the data is quite huge.
 
Last edited:

Excel Facts

Can you sort left to right?
To sort left-to-right, use the Sort dialog box. Click Options. Choose "Sort left to right"
Assuming that combinations such as A and 1 can occur more than once and the intention is to collect (sum) items sold (i.e. quanties), you can set up a range processing formula (with SUMIFS) instead of one that does array processing (like with SUMPRODUCT)...

In G2 just enter, copy across, and down:

=SUMIFS($C$2:$C$6,$A$2:$A$6,$A2,$B$2:$B$6,G$1)

This is also faster.
 
Upvote 0
This looks to be a perfect candidate for a PivotTable.
Place the Employee field in the PivotTable Rows, Item Code in the Columns and Items Sold in Values (with Sum selected).
 
Last edited:
Upvote 0
Assuming that combinations such as A and 1 can occur more than once and the intention is to collect (sum) items sold (i.e. quanties), you can set up a range processing formula (with SUMIFS) instead of one that does array processing (like with SUMPRODUCT)...

In G2 just enter, copy across, and down:

=SUMIFS($C$2:$C$6,$A$2:$A$6,$A2,$B$2:$B$6,G$1)

This is also faster.
Thanks Aladin, the intention is to retrieve the value not sum it. The combination will occur only once; however, I don't know how to get the vlookup or index and match working so i used sumproduct.
 
Upvote 0
So, is there be a better function to be used, if the sum is not required ?
 
Upvote 0
Thanks Aladin, the intention is to retrieve the value not sum it. The combination will occur only once; however, I don't know how to get the vlookup or index and match working so i used sumproduct.

So, is there be a better function to be used, if the sum is not required ?

In G2 control+shift+enter, not just enter, copy across, and down:

=IFNA(INDEX($C$2:$C$6,MATCH($F2,IF($B$2:$B$6=G$1,$A$2:$A$6),0)),"")

Note. If your Excel does not list IFNA, replace it in the formula with IFERROR.
 
Upvote 0
Thanks Aladin. Does index/Match work faster than SUMIFS?
 
Upvote 0
Since the Index-match version which you gave is an array formula whereas your SUMIFS version is a non-array formula. So I am confused as to which will be faster.
 
Upvote 0
Since the Index-match version which you gave is an array formula whereas your SUMIFS version is a non-array formula. So I am confused as to which will be faster.

You can try to time these formulas. It's possibly the SUMIFS formula that is faster. Conceptually, the conditional INDEX/MATCH is the appropriate fit.
 
Upvote 0

Forum statistics

Threads
1,215,446
Messages
6,124,900
Members
449,194
Latest member
JayEggleton

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