Formula to encompass multiple references and date range

M3dagr8

New Member
Joined
Sep 8, 2022
Messages
10
Office Version
  1. 365
Platform
  1. Windows
Hello guys I am badly stuck on this situation and need help. I have 2 sheets open. Sheet one has 2 columns account number and a disconnect date and sheet 2 has 2 columns account number and payment date. I need to setup a formula so that I can bring dates from sheet 2 into sheet 1, if the date in sheet 2 is within 45 days of the matches date in sheet 1. Now the issue is that I have multiple entries from the same account number and if I use vlookup it only pulls the first date associated with the account number. I need a formula that could go down the line and use all of the dates to match the data associated with one account number.
1662658690964.png
1662658754723.png
 

Excel Facts

Excel motto
Not everything I do at work revolves around Excel. Only the fun parts.
I don't quite understand what you want. Given this for Sheet2:
Book1
AB
1Account NbrOriginal Payment Date
270161684/19/2022
398130364/22/2022
498130367/4/2022
5190863307/19/2022
6190863307/3/2022
7200863306/20/2022
83111237210/17/2022
9311123723/14/2022
10311123724/26/2022
Sheet2

One approach to return what you've described is shown here, but note that you can get multiple results (so I've concatenated the dates, separated by commas). Let me know if your filtering criteria need to be revised:
Book1
ABC
1Account NbrDisconnect DateOriginal Payment Date
298130368/23/202204/22/2022, 07/04/2022
398130366/23/202204/22/2022, 07/04/2022
498130364/11/202204/22/2022
598130362/21/2022 
698130361/3/2022 
798130366/15/202204/22/2022, 07/04/2022
8200863308/10/202206/20/2022
9311123728/11/202203/14/2022, 04/26/2022
10311123728/24/202203/14/2022, 04/26/2022
11311123726/8/202203/14/2022, 04/26/2022
12311123724/14/202203/14/2022, 04/26/2022
13311123722/28/202203/14/2022
14311123721/10/2022 
Sheet1
Cell Formulas
RangeFormula
C2:C14C2=TEXTJOIN(", ",TRUE,TRANSPOSE(TEXT(FILTER(Sheet2!$B$2:$B$10,(Sheet2!$A$2:$A$10=A2)*(Sheet2!$B$2:$B$10<=(B2+45)),""),"mm/dd/yyyy")))
 
Upvote 0
Hey KRice sorry if I wasn't clear enough with my issue. I will try to explain it again I have pulled data from 2 sources for sheet 1 it was disconnection date and for sheet 2 it was original payment date. Both sources include show data as line item entries, so it would have an account number and when either the original payment was or disconnection was. I need to figure out a method where I am able to identify if a payment was made within 45 days of a disconnection date. So the formula in sheet 1 in cell C2 would be able to only bring a date from sheet 2 if (1) the account numbers match and (2) the original payment date is within 45 days of the disconnection date. The issue is there are multiple line item entries made on both sheets per account. I really liked your concatenated approach! But to be truly honest I had a hard time understanding your formula (since all of this is not in my ball park yet!) Your help would be greatly appreciated.
 
Upvote 0
Thanks for the clarification. Could you go a little further, please? I'm trying to determine the specific date criteria. Are you saying that for any given Disconnect Date (let's call this date D), if we go back 45 days (let's call this date D-45), you want to consider any Payment Dates made between D-45 and D? Or are you saying to go forward 45 days from D (let's call this D+45), and we want any Payment Dates between D and D+45? Or do you want to go in both directions and consider any Payment Date between D-45 and D+45?
 
Upvote 0
Thanks for the clarification. Could you go a little further, please? I'm trying to determine the specific date criteria. Are you saying that for any given Disconnect Date (let's call this date D), if we go back 45 days (let's call this date D-45), you want to consider any Payment Dates made between D-45 and D? Or are you saying to go forward 45 days from D (let's call this D+45), and we want any Payment Dates between D and D+45? Or do you want to go in both directions and consider any Payment Date between D-45 and D+45?
Yes so I need it to go forward. So 45 days after the disconnection date that is where the original payment should fall
 
Upvote 0
Thanks for the clarification. I made one adjustment, adding one condition to the FILTER criteria constraining the Payment Date to occur on or after the Disconnect Date. So the three FILTER criteria are to 1) match the Account Number, 2) Payment occurs on or after Disconnect Date, and 3) Payment occurs on or before the Disconnect Date + 45 days. In this example, there are not multiple returns, so TEXTJOIN may not be necessary as a way of stringing together multiple returns. In reality, will there ever be two or more answers that might justify keeping TEXTJOIN...or would the internal FILTER part of the formula be sufficient to return either one date or a blank? If no more than one date will ever be returned, the version of the formula in the blue cells would be simpler.
MrExcel_20220909.xlsx
ABCD
1Account NbrDisconnect DateOriginal Payment Date
298130368/23/2022  
398130366/23/202207/04/20227/4/2022
498130364/11/202204/22/20224/22/2022
598130362/21/2022  
698130361/3/2022  
798130366/15/202207/04/20227/4/2022
8200863308/10/2022  
9311123728/11/2022  
10311123728/24/2022  
11311123726/8/2022  
12311123724/14/202204/26/20224/26/2022
13311123722/28/202203/14/20223/14/2022
14311123721/10/2022  
Sheet1
Cell Formulas
RangeFormula
C2:C14C2=TEXTJOIN(", ",TRUE,TRANSPOSE(TEXT(FILTER(Sheet2!$B$2:$B$10,(Sheet2!$A$2:$A$10=A2)*(Sheet2!$B$2:$B$10<=(B2+45))*(Sheet2!$B$2:$B$10>=B2),""),"mm/dd/yyyy")))
D2:D14D2=FILTER(Sheet2!$B$2:$B$10,(Sheet2!$A$2:$A$10=A2)*(Sheet2!$B$2:$B$10<=(B2+45))*(Sheet2!$B$2:$B$10>=B2),"")
 
Upvote 0
Solution
Thank you soo much Krice! The version with 2 potential answers seems to be what I was looking for. You have really saved me a massive headache with this!!!
 
Upvote 0
You're welcome...I'm happy to help. I wasn't sure about the number of dates that might be returned. The FILTER formula will return them, but you will get a spill error because there isn't room for the results to spill downward. You could wrap the FILTER function with a TRANSPOSE to get multiple results to spill to the right across multiple columns (if that is desired)...that would look like =TRANSPOSE(FILTER(...))
But if you might have multiple dates returned and you want all of them consolidated in a single cell, the TEXTJOIN offering would be preferred.
 
Upvote 0
Hey KRice I have an issue coming up. When I insert the text join formula I keep getting the #N/A error and when I use the Filter formula wrapped in transpose then it gives me a blank cell. I've looked over your formula many times and the issue still persists. Any tips?
 
Upvote 0
Could you go to a cell where this error appears, copy the formula, and then paste it into a post?
 
Upvote 0

Forum statistics

Threads
1,214,907
Messages
6,122,185
Members
449,071
Latest member
cdnMech

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