Formula to show the earliest date from a range with criteria

TruffleOil

New Member
Joined
Sep 9, 2022
Messages
18
Office Version
  1. 2016
Platform
  1. Windows
I have a set of data (see picture attached), where different projects have several dates, even within same month (A3:B16). My goal is to build a ''calendar'' that will show Projects and their first date that will fit within the selected month.

E.g. in the picture: I want to see the projects that have dates that fall within January 2023 as per G3, but I don't want to see all their dates and repeated name of the projects. So for project A, which has multiple dates in January (B7:B10), I just want to see the first/earliest date from that project in January, which is 01/05/2023. Same applies to Project B.

Would appreciate if anyone could help to come up with a formula (maybe Index Match?) for D4 and E4!

Thank you!
 

Attachments

  • excel question 8.PNG
    excel question 8.PNG
    23.6 KB · Views: 38

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.
This seems too cumbersome to me.
MrExcelPlayground14.xlsx
ABCDEFG
2Project
3A12/15/2022ProjectDate1/1/2023
4A12/22/2022A1/5/2023
5A12/29/2022B1/8/2023
6A1/5/2023
7A1/12/2023
8A1/19/2023
9A1/26/2023
10B1/8/2023
11B1/16/2023
12B7/6/2023
13B7/13/2023
14B7/20/2023
15B7/27/2023
Sheet32
Cell Formulas
RangeFormula
E4:E5E4=MIN(IF(($A$3:$A$15=D4)*(MONTH($B$3:$B$15)=MONTH($G$3))*(YEAR($B$3:$B$15)=YEAR($G$3)),$B$3:$B$15,99999))
 
Upvote 0
Another Option

Book3
ABCDEFGHIJ
1
2Source Data
3Project NameDateProject NameDateJanuary2023
4A12/15/2022A1/5/20231/1/20231/31/2023
5A12/22/2022B1/8/2023
6A12/29/2022
7A1/5/2023
8A1/12/2023
9A1/19/2023
10A1/26/2023
11B1/8/2023
12B1/16/2023
13B7/16/2023
14B7/13/2023
15B7/20/2023
16B7/27/2023
17
18
Sheet1
Cell Formulas
RangeFormula
E4:E5E4=INDEX($B$4:$B$16,AGGREGATE(15,6,(ROW($B$4:$B$16)-ROW($B$4)+1)/($B$4:$B$16>=$H$4)/($B$4:$B$16<=$I$4)/($A$4:$A$16=$D4),1))
 
Upvote 0
This seems too cumbersome to me.
MrExcelPlayground14.xlsx
ABCDEFG
2Project
3A12/15/2022ProjectDate1/1/2023
4A12/22/2022A1/5/2023
5A12/29/2022B1/8/2023
6A1/5/2023
7A1/12/2023
8A1/19/2023
9A1/26/2023
10B1/8/2023
11B1/16/2023
12B7/6/2023
13B7/13/2023
14B7/20/2023
15B7/27/2023
Sheet32
Cell Formulas
RangeFormula
E4:E5E4=MIN(IF(($A$3:$A$15=D4)*(MONTH($B$3:$B$15)=MONTH($G$3))*(YEAR($B$3:$B$15)=YEAR($G$3)),$B$3:$B$15,99999))
[/RANt
Cell Formulas
RangeFormula

Another Option

Book3
ABCDEFGHIJ
1
2Source Data
3Project NameDateProject NameDateJanuary2023
4A12/15/2022A1/5/20231/1/20231/31/2023
5A12/22/2022B1/8/2023
6A12/29/2022
7A1/5/2023
8A1/12/2023
9A1/19/2023
10A1/26/2023
11B1/8/2023
12B1/16/2023
13B7/16/2023
14B7/13/2023
15B7/20/2023
16B7/27/2023
17
18
Sheet1
Cell Formulas
RangeFormula
E4:E5E4=INDEX($B$4:$B$16,AGGREGATE(15,6,(ROW($B$4:$B$16)-ROW($B$4)+1)/($B$4:$B$16>=$H$4)/($B$4:$B$16<=$I$4)/($A$4:$A$16=$D4),1))
thank you for replying! the formulas work great, but I would also like to have a formula that selects the projects (D4) based on the same criteria as the dates (E4). for instance, there might be other projects in the source data, such as Project C, D, E, etc. that do not have any January dates, so from a big data source, I wouldn't know which ones would fit within the January period, sorry if I didn't elaborate that in the post. in these formulas I tried, it already assumes that the dates belong to those projects, but realistically I don't know which projects should be there either
 
Upvote 0
This is the part where I recommend excel 365. It would make quick work of this whole thing. Below is a bit of a mess.

MrExcelPlayground14.xlsx
ABCDEFG
2Project
3A12/15/2022ProjectDate1/1/2023
4A12/22/2022  
5A12/29/2022B1/8/2023
6A1/5/2023A1/5/2023
7A1/12/2023  
8A1/19/2023  
9A1/26/2023  
10B1/8/2023  
11B1/16/2023  
12B7/6/2023  
13B7/13/2023  
14B7/20/2023  
15B7/27/2023  
16C12/15/2022  
17C2/2/2022  
18C2/5/2023
19C2/10/2023
Sheet32
Cell Formulas
RangeFormula
D4:D17D4=IFERROR(LOOKUP(2,1/(COUNTIF($D$3:D3,IF((MONTH($B$3:$B$19)=MONTH($G$3))*(YEAR($B$3:$B$19)=YEAR($G$3)),$A$3:$A$19,""))=0),IF((MONTH($B$3:$B$19)=MONTH($G$3))*(YEAR($B$3:$B$19)=YEAR($G$3)),$A$3:$A$19,"")),"")
E4:E17E4=IFERROR(1/(1/(MIN(IF(($A$3:$A$19=D4)*(MONTH($B$3:$B$19)=MONTH($G$3))*(YEAR($B$3:$B$19)=YEAR($G$3)),$B$3:$B$19,"")))),"")
 
Upvote 0
Solution
This is the part where I recommend excel 365. It would make quick work of this whole thing. Below is a bit of a mess.

MrExcelPlayground14.xlsx
ABCDEFG
2Project
3A12/15/2022ProjectDate1/1/2023
4A12/22/2022  
5A12/29/2022B1/8/2023
6A1/5/2023A1/5/2023
7A1/12/2023  
8A1/19/2023  
9A1/26/2023  
10B1/8/2023  
11B1/16/2023  
12B7/6/2023  
13B7/13/2023  
14B7/20/2023  
15B7/27/2023  
16C12/15/2022  
17C2/2/2022  
18C2/5/2023
19C2/10/2023
Sheet32
Cell Formulas
RangeFormula
D4:D17D4=IFERROR(LOOKUP(2,1/(COUNTIF($D$3:D3,IF((MONTH($B$3:$B$19)=MONTH($G$3))*(YEAR($B$3:$B$19)=YEAR($G$3)),$A$3:$A$19,""))=0),IF((MONTH($B$3:$B$19)=MONTH($G$3))*(YEAR($B$3:$B$19)=YEAR($G$3)),$A$3:$A$19,"")),"")
E4:E17E4=IFERROR(1/(1/(MIN(IF(($A$3:$A$19=D4)*(MONTH($B$3:$B$19)=MONTH($G$3))*(YEAR($B$3:$B$19)=YEAR($G$3)),$B$3:$B$19,"")))),"")
oh wow it worked, thank you so much!! yes, I'm looking to update to office 365, it's much easier with formulas. what kind of formula would you use for office 365, out of curiosity?
 
Upvote 0
In 365 - exactly one formula solves the whole thing.

MrExcelPlayground14.xlsx
ABCDE
11/1/2023
2Project
3A12/15/2022A1/5/2023
4A12/22/2022B1/8/2023
5A12/29/2022
6A1/5/2023
7A1/12/2023
8A1/19/2023
9A1/26/2023
10B1/8/2023
11B1/16/2023
12B7/6/2023
13B7/13/2023
14B7/20/2023
15B7/27/2023
16C12/15/2022
17C2/2/2022
18C2/5/2023
19C2/10/2023
Sheet32
Cell Formulas
RangeFormula
D3:E4D3=LET(a,(FILTER(A3:B19,(MONTH(B3:B19)=MONTH(D1))*(YEAR(B3:B19)=YEAR(D1)))),b,SORT(SORT(a,2),1),c,UNIQUE(INDEX(a,,1)),d,XLOOKUP(c,INDEX(b,,1),INDEX(b,,2),,1),IF(ISODD(SEQUENCE(ROWS(d),2)),c,d))
Dynamic array formulas.
 
Upvote 0
Another option for 365
Fluff.xlsm
ABCDE
101/01/2023
2Project
3A15/12/2022A05/01/2023
4A22/12/2022B08/01/2023
5A29/12/2022
6A05/01/2023
7A12/01/2023
8A19/01/2023
9A26/01/2023
10B08/01/2023
11B16/01/2023
12B06/07/2023
13B13/07/2023
14B20/07/2023
15B27/07/2023
16C15/12/2022
17C02/02/2022
18C05/02/2023
19C10/02/2023
20
Data
Cell Formulas
RangeFormula
D3:E4D3=LET(u,UNIQUE(FILTER(A3:A100,(B3:B100>=D1)*(B3:B100<=EOMONTH(D1,0)))),HSTACK(u,MINIFS(B:B,A:A,u,B:B,">="&D1)))
Dynamic array formulas.
Named Ranges
NameRefers ToCells
_FilterDatabase=Data!$B$1:$B$19D3
 
Upvote 0

Forum statistics

Threads
1,223,888
Messages
6,175,203
Members
452,617
Latest member
Narendra Babu D

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