Xlookup with Date

kumara_faith

Well-known Member
Joined
Aug 19, 2006
Messages
955
Office Version
  1. 365
Hi,

I have the following table:

Book1
BCDEFGHIJK
2Table 1Table 2
3NameDateBranchNameBranch1Transfer DateBranch2Transfer DateBranch3
4Jonas1/10/2023ChicagoJonasChicago
5Danny1/10/2023DallasDannyDallas
6Michelle1/10/2023New YorkMichelleNew York4/10/2023Baltimore1/11/2023Los Angeles
7Jonas1/10/2023Chicago
8Danny5/10/2023Dallas
9Michelle4/10/2023Baltimore
10Jonas1/10/2023Chicago
11Danny1/10/2023Dallas
12Michelle7/10/2023Baltimore
13Jonas4/11/2023Chicago
14Danny4/11/2023Dallas
15Michelle4/11/2023Los Angeles
Sheet1


In Table 1 I have the name of staffs, the date of the transaction and their branch . In Table 2, I have the name of the staffs and information if there have been transferred and their respective transfer date. Michelle was in New York until she was transferred to Baltimore on 4/10/23 and then again transferred to LA on 1/11/23. As such, the branch name in column D shows the branch according to Table 2. I am trying to use a xlookup to populate the correct branch in column D but I cant seems to include the date logic. Is there any way to get the right results in column D with a formula ? Thanks for all the help.
 

Excel Facts

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.
Try this;

This requires the time line (with respect to each name) is squential, even though I do not use the date in the formula.


Book1
ABCDEFGHIJK
1Table 1Table 2
2NameDateBranchNameBranch1Transfer DateBranch2Transfer DateBranch3
3Jonas2023-10-01ChicagoJonasChicago
4Danny2023-10-01DallasDannyDallas
5Michelle2023-10-01New YorkMichelleNew York2023-10-04Baltimore2023-11-01Los Angeles
6Jonas2023-10-01Chicago
7Danny2023-10-05Dallas
8Michelle2023-10-04Baltimore
9Jonas2023-10-01Chicago
10Danny2023-10-01Dallas
11Michelle2023-10-07Los Angeles
12Jonas2023-11-04Chicago
13Danny2023-11-04Dallas
14Michelle2023-11-04Los Angeles
15
Sheet2
Cell Formulas
RangeFormula
C3:C14C3=INDEX(TOROW(CHOOSECOLS(FILTER($E$3:$J$5,$E$3:$E$5=A3),2,4,6),1),, MIN(COUNTA(TOROW(CHOOSECOLS(FILTER($E$3:$J$5,$E$3:$E$5=A3),2,4,6),1)),COUNTIF($A$3:$A3,A3)))
 
Upvote 0
Hi awoohaw,

Thank you for your response. The branch for Michelle for 7/10/2023 should be Baltimore instead of LA. Please assist.
 
Upvote 0
Okay, try this:
Mr Excel Questions 71.xlsm
ABCDEFGHIJKL
1Table 1Table 2
2NameDateBranchNameBranch1Transfer DateBranch2Transfer DateBranch3
3Jonas2023-10-01ChicagoJonasChicago
4Danny2023-10-01DallasDannyDallas
5Michelle2023-10-01New YorkMichelleNew York2023-10-04Baltimore2023-11-01Los Angeles
6Jonas2023-10-01Chicago
7Danny2023-10-05Dallas
8Michelle2023-10-04Baltimore
9Jonas2023-10-01Chicago
10Danny2023-10-01Dallas
11Michelle2023-10-07Baltimore
12Jonas2023-11-04Chicago
13Danny2023-11-04Dallas
14Michelle2023-11-04Los Angeles
15
kumara_faith
Cell Formulas
RangeFormula
C3:C14C3=LET(KeyDate, B3, FrstBranch,XLOOKUP(A3,$E$3:$E$5,$F$3:$F$5), MultCity,CHOOSECOLS(FILTER($E$3:$J$5,$E$3:$E$5=A3),4,6), MultDates,CHOOSECOLS(FILTER($E$3:$J$5,$E$3:$E$5=A3),3,5), CityMatch,XLOOKUP(KeyDate,MultDates,MultCity,,-1), IFERROR(CityMatch,FrstBranch))
 
Upvote 0
Solution
Hi awoohaw,

That you for your response and that worked. Appreciate your patience and have a great day ahead. 🙏
 
Upvote 0
Hi awoohaw,

That you for your response and that worked. Appreciate your patience and have a great day ahead. 🙏
I am happy you found a solution here. Welcome to the Mr. Excel forum.

Best Wishes!
 
Upvote 0

Forum statistics

Threads
1,224,827
Messages
6,181,199
Members
453,022
Latest member
RobertV1609

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