How does XLOOKUP do the lookup based on two criteria?

OaklandJim

Well-known Member
Joined
Nov 29, 2018
Messages
849
Office Version
  1. 365
Platform
  1. Windows
Team Excel

Somewhere on the web I found syntax for using XLOOKUP to do the lookup based on two lookup criteria. But I'd like to understsand how it works. This XLOOKUP formula looks up quantity for a specified stock symbol and for a specific account. (Two accounts have the same stock.) I'd like to know how this works.

XLOOKUP(1,(Summary!Symbols=rrSymbol)*(Summary!AccountNumbers=rrAccountNumber),Summary!Quantities)

(rr signifies "relative row" addressing.)

I appreciate your help.
 

Excel Facts

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.
Does this help?

ABCDEFGHI
1In detail ...
2StockAccountQuantityStock match?Account match?Both match?Quantity
3A12FALSEFALSE02
4B13TRUEFALSE03
5A25FALSETRUE05
6B27TRUETRUE17
7C111FALSEFALSE011
8D113FALSEFALSE013
9A317FALSEFALSE017
10D219FALSETRUE019
11
12Lookup
13B27
147
15
Sheet1
Cell Formulas
RangeFormula
F3:G10F3=B3:B10=B13
H3:H10H3=F3#*G3#
I3:I10I3=D3:D10
D13D13=XLOOKUP(1,(B3:B10=B13)*(C3:C10=C13),D3:D10)
D14D14=XLOOKUP(1,H3#,I3:I10)
Dynamic array formulas.


Note that XLOOKUP will find only the first occurrence. If there is a possibility of multiple matches, you'd use FILTER instead.
 
Upvote 0
Go to the Formulas tab and look for the Evaluate Formula button. Select the cell with the formula, then click Evaluate Formula, and you can step through it to see how it works.

But for your formula, the basic idea is that the (Summary!Symbols=rrSymbol) part creates an array of TRUE/FALSE values, so the array has as many entries as Summary!Symbols does, for example {TRUE,TRUE,FALSE,FALSE, . . .}. Then the (Summary!AccountNumbers=rrAccountNumber) part creates another similar array of the same size, {FALSE,TRUE,FALSE,FALSE, . . .}. Then the 2 arrays are multiplied together, item by item. And when multiplying Boolean values, they're converted to 1s and 0s, so those 2 arrays multiplied together become {0,1,0,0, . . .}. Then the XLOOKUP looks for a 1 in that array, and returns the value from Summary!Quantities in the same position.

Hope this helps!
 
Upvote 0

Forum statistics

Threads
1,221,537
Messages
6,160,405
Members
451,644
Latest member
hglymph

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