Two-way XLOOKUP() w/ Multiple Lookup Values (Range)

TheMacroNoob

Board Regular
Joined
Aug 5, 2022
Messages
52
Office Version
  1. 365
Platform
  1. Windows
Hello excel experts,

I am using a two-way XLOOKUP() to grab a range of lookup values from a dynamic column lookup.

The formula I am currently using is:
=SUM(XLOOKUP($C$11:$C$43,INDIRECT("'"&G$10&"'!"&"$A:$A"),XLOOKUP($D11,INDIRECT("'"&G$10&"'!"&"$6:$6"),INDIRECT("'"&G$10&"'!"&"$1:$1048576"))))

The INDIRECT() formulas are for a dynamic sheet reference, otherwise it would simply look like this:
=SUM(XLOOKUP($C$11:$C$43,'2018'!$A:$A,XLOOKUP($D11,'2018'!$6:$6,'2018'!$1:$1048576)))

The problem is, once the formula comes up on sheet that is missing one or more of the lookup values in the range $C$11:$C$43, an #N/A error is returned.

How can I make the formula skip or replace with 0 any missing values in the lookup range? Does the entire formula need to be scrapped and re-worked?

Expense Summary.xlsx
CDEFGHIJ
102018201920202021
115139-9998107275380427582483277774#N/A
125159-9999109412119042209444550497#N/A
135189-9998110269365525742102589297#N/A
145162-0000121329754034966414173730#N/A
155163-0000165315128031945313503053#N/A
165180-0000328398963138256843741355#N/A
175181-0000331191997319122101919059#N/A
Sheet1
Cell Formulas
RangeFormula
G11:J17G11=SUM(XLOOKUP($C$11:$C$43,INDIRECT("'"&G$10&"'!"&"$A:$A"),XLOOKUP($D11,INDIRECT("'"&G$10&"'!"&"$6:$6"),INDIRECT("'"&G$10&"'!"&"$1:$1048576"))))
 

Excel Facts

Test for Multiple Conditions in IF?
Use AND(test, test, test, test) or OR(test, test, test, ...) as the logical_test argument of IF.
Okay, I overlooked the logic of the XLOOKUP's "if not found" argument. I needed to put 0 in a couple positions in the "if not found" XLOOKUP functions.
=SUM(XLOOKUP(IF($C$6="All",$C$11:$C$43,INDEX($C$11:$C$43,XMATCH($C$6,$B$11:$B$43))),INDIRECT("'"&G$10&"'!"&"$A:$A"),XLOOKUP($D11,INDIRECT("'"&G$10&"'!"&"$6:$6"),INDIRECT("'"&G$10&"'!"&"$1:$1048576"),0),0))
 
Upvote 0
Solution

Forum statistics

Threads
1,223,885
Messages
6,175,179
Members
452,615
Latest member
bogeys2birdies

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