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
 
=TEXTJOIN(",",TRUE,TRANSPOSE(TEXT(FILTER(Sheet2!$B$2:$B$3047,(Sheet2!$A$2:$A$3047=Sheet1!A3)*(Sheet2!$B$2:$B$3047<=(Sheet1!B3+45))*(Sheet2!B3:$B$3047>=Sheet1!B3),""),"mm/dd/yyyy")))
This is what the formula looks like. I sent you a sample file with some made up accounts. But the actual list of accounts is quiet big
 
Upvote 0

Excel Facts

Select all contiguous cells
Pressing Ctrl+* (asterisk) will select the "current region" - all contiguous cells in all directions.
In your formula, you have a Sheet2!B3:$B$3047 but it should be Sheet2!$B$2:$B$3047...and that will produce errors when you attempt to multiple the arrays. So try:
=TEXTJOIN(",",TRUE,TRANSPOSE(TEXT(FILTER(Sheet2!$B$2:$B$3047,(Sheet2!$A$2:$A$3047=Sheet1!A3)*(Sheet2!$B$2:$B$3047<=(Sheet1!B3+45))*(Sheet2!$B$2:$B$3047>=Sheet1!B3),""),"mm/dd/yyyy")))
 
Upvote 0
=TEXTJOIN(",",TRUE,TRANSPOSE(TEXT(FILTER(Sheet2!$B$2:$B$3047,(Sheet2!$A$2:$A$3047=Sheet1!A2)*(Sheet2!$B$2:$B$3047<=(Sheet1!B2+45))*(Sheet2!B2:$B$3047>=Sheet1!B2),""),"mm/dd/yyyy")))

So this was the formula for cell C2 while the one I sent previously was for cell C3
 
Upvote 0
Ok now I fixed that issue and the N/A turned into blanks

=TEXTJOIN(",",TRUE,TRANSPOSE(TEXT(FILTER(Sheet2!$B$2:$B$3047,(Sheet2!$A$2:$A$3047=Sheet1!A2)*(Sheet2!$B$2:$B$3047<=(Sheet1!B2+45))*(Sheet2!$B$2:$B$3047>=Sheet1!B2),""),"mm/dd/yyyy")))
 
Upvote 0
Yes...I understood that. But the point remained, you want to FILTER Sheet2!$B$2:$B$3047, which is a fixed range. To do that, you need to make sure that all of your filtering criteria use the same range from rows 2 to 3047. So making the change I described fixes the issue...and those ranges need to be "fixed" with the $ sign so that they do not change as the formula is copied.
 
Upvote 0
Yes...I understood that. But the point remained, you want to FILTER Sheet2!$B$2:$B$3047, which is a fixed range. To do that, you need to make sure that all of your filtering criteria use the same range from rows 2 to 3047. So making the change I described fixes the issue...and those ranges need to be "fixed" with the $ sign so that they do not change as the formula is copied.
Hey KRice could you check this I think its now updated:
=TEXTJOIN(",",TRUE,TRANSPOSE(TEXT(FILTER(Sheet2!$B$2:$B$3047,(Sheet2!$A$2:$A$3047=Sheet1!A2)*(Sheet2!$B$2:$B$3047<=(Sheet1!B2+45))*(Sheet2!$B$2:$B$3047>=Sheet1!B2),""),"mm/dd/yyyy")))
This has turned the cells blank
 
Upvote 0
I don't see any problem with the formula. Is it working as expected?
You could add one extra feature to the formula: in the case where multiple results are returned, you could sort them from earliest to latest dates by including the SORT function:
Excel Formula:
=TEXTJOIN(",",TRUE,TRANSPOSE(TEXT(SORT(FILTER(Sheet2!$B$2:$B$3047,(Sheet2!$A$2:$A$3047=Sheet1!A2)*(Sheet2!$B$2:$B$3047<=(Sheet1!B2+45))*(Sheet2!$B$2:$B$3047>=Sheet1!B2),"")),"mm/dd/yyyy")))
 
Upvote 0
I don't see any problem with the formula. Is it working as expected?
You could add one extra feature to the formula: in the case where multiple results are returned, you could sort them from earliest to latest dates by including the SORT function:
Excel Formula:
=TEXTJOIN(",",TRUE,TRANSPOSE(TEXT(SORT(FILTER(Sheet2!$B$2:$B$3047,(Sheet2!$A$2:$A$3047=Sheet1!A2)*(Sheet2!$B$2:$B$3047<=(Sheet1!B2+45))*(Sheet2!$B$2:$B$3047>=Sheet1!B2),"")),"mm/dd/yyyy")))
That didn't fix the issue. I haven't really encountered empty cells, usually there is some sort of error either Ref or N/A but this is just blank
 
Upvote 0
I do not understand the issue you are having. The formula will produce a blank if the filtering criteria find no rows where all three criteria are met (account is matched, payment date is on or before Disconnect +45, and payment date occurs on or after Disconnect Date). Are you seeing blanks for those rows?
 
Upvote 0

Forum statistics

Threads
1,214,979
Messages
6,122,551
Members
449,088
Latest member
davidcom

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