Checking dates within a range in a lookup

IncrediBulk

New Member
Joined
Oct 28, 2024
Messages
2
Office Version
  1. 365
Platform
  1. Windows
Hello all

I've been asked to clean up some data in our system and have hit a bit of a snag

We have case files and then case sessions. Each holds an owner field... and they should always match when a case session is created

Case owner Bob, case session owner at creation will be Bob
Case owner changes to John, all new case sessions with have John as the owner

We had a previous bug which did not do this properly and has left hundreds of blank owners in case sessions. I have been able to sort out most of them but now have an issue when the Case Owner has changed multiple times.

I'm looking for a way to compare the creation date on a session against the dates that the Case Owners changed and then picking the correct owner to assign

1730170116938.png


1730170228494.png


So for this example from the second image, the expected results would be;

Bob
Mark
Jane
Mark
Cara
Cara
 

Excel Facts

Difference between two dates
Secret function! Use =DATEDIF(A2,B2,"Y")&" years"&=DATEDIF(A2,B2,"YM")&" months"&=DATEDIF(A2,B2,"MD")&" days"
Welcome to the MrExcel forum!

Try:

Book2
ABCDEFGHIJ
1File NumberDateOld Value NameNew Value Nameint_serviceecreatedonint_filenumberName
2SF01331843/2/2021 12:32 PMJohnJaneSE-18214571/6/2021 12:00 AMSF0149145Bob
3SF014914518/6/2021 10:15 AMBobMarkSE-182145830/6/2023 12:00 AMSF0149145Mark
4SF013318417/8/2021 10:38 AMSaraCaraSE-182145624/4/2023 6:26 AMSF0149145Jane
5SF014914512/4/2023 10:33 AMJohnJaneSE-184324615/3/2024 12:00 AMSF0149145Mark
6SF014914527/6/2023 7:54 AMBobMarkSE-184324411/7/2023 2:06 AMSF0149145Mark
7SF01762373/7/2023 9:00 AMSaraCaraSE-184324829/10/2024 12:00 AMSF0149145Cara
8SF01762377/10/2023 1:29 PMJohnJane
9SF014914522/12/2023 11:21 AMBobMark
10SF014914520/6/2024 3:43 AMSaraCara
Sheet5
Cell Formulas
RangeFormula
J2:J7J2=XLOOKUP(H2,FILTER(B$2:B$10,A$2:A$10=I2),FILTER(D$2:D$10,A$2:A$10=I2),XLOOKUP(I2,A$2:A$10,C$2:C$10,"??",0),-1,1)


Notice that I got a different result for the second to last line, Please check that.
 
Upvote 0
No you were correct, I got the years mixed up while writing out the expected results. That formula is incredible! I'll give it a try in my file

Thank you!!!!
 
Upvote 0
Here's a slightly shorter version that might be a bit easier to follow:

Excel Formula:
=LET(t,$A$2:$D$10,d,H2,fn,I2,f,FILTER(t,INDEX(t,0,1)=fn),XLOOKUP(d,INDEX(f,0,2),INDEX(f,0,4),INDEX(f,1,3),-1,1))

Glad to help! Let us know if you need anything else. :cool:
 
Upvote 0

Forum statistics

Threads
1,224,820
Messages
6,181,157
Members
453,021
Latest member
Justyna P

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