Re: Some advanced Index Match (or something else?) - Please help!
Alhelor: you certainly do like the complicated formulas!
Consider this:
| A | B | C | D | E | F |
---|
Project | Resource | Consumed © or Produced (P) | Date of occurrence | | | |
A | Car | P | | | | |
B | Computer | C | | | | |
C | Computer | C | | | | |
C | Car | P | | | | |
C | Cake | P | | | | |
D | Car | P | | | | |
D | Computer | C | | | | |
D | Cookies | C | | | | |
E | Computer | C | | | | |
E | Bike | P | | | | |
F | Computer | C | | | | |
F | Car | P | | | | |
| | | | | | |
What is the earliest date at which a computer is consumed to create a car within the same project? | | | | | | |
| | | | | | |
Project | Produced | Consumed | Earliest Consumption Date | | | |
D | Car | Computer | | | | |
<colgroup><col style="width: 25pxpx"><col><col><col><col><col><col></colgroup><thead>
</thead><tbody>
[TD="align: center"]1[/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: center"]2[/TD]
[TD="align: right"]12/1/2015[/TD]
[TD="align: right"]0[/TD]
[TD="align: right"]11/18/1999[/TD]
[TD="align: center"]3[/TD]
[TD="align: right"]7/5/2017[/TD]
[TD="align: right"]0[/TD]
[TD="align: right"][/TD]
[TD="align: center"]4[/TD]
[TD="align: right"]8/1/2019[/TD]
[TD="align: right"]0[/TD]
[TD="align: right"][/TD]
[TD="align: center"]5[/TD]
[TD="align: right"]3/1/2014[/TD]
[TD="align: right"]0[/TD]
[TD="align: right"][/TD]
[TD="align: center"]6[/TD]
[TD="align: right"]5/3/2018[/TD]
[TD="align: right"]0[/TD]
[TD="align: right"][/TD]
[TD="align: center"]7[/TD]
[TD="align: right"]6/25/2020[/TD]
[TD="align: right"]1[/TD]
[TD="align: right"][/TD]
[TD="align: center"]8[/TD]
[TD="align: right"]11/18/1999[/TD]
[TD="align: right"]1[/TD]
[TD="align: right"][/TD]
[TD="align: center"]9[/TD]
[TD="align: right"]2/19/2011[/TD]
[TD="align: right"]1[/TD]
[TD="align: right"][/TD]
[TD="align: center"]10[/TD]
[TD="align: right"]1/1/1970[/TD]
[TD="align: right"]0[/TD]
[TD="align: right"][/TD]
[TD="align: center"]11[/TD]
[TD="align: right"]4/2/1971[/TD]
[TD="align: right"]0[/TD]
[TD="align: right"][/TD]
[TD="align: center"]12[/TD]
[TD="align: right"][/TD]
[TD="align: right"]0[/TD]
[TD="align: right"][/TD]
[TD="align: center"]13[/TD]
[TD="align: right"]2/1/2015[/TD]
[TD="align: right"]0[/TD]
[TD="align: right"][/TD]
[TD="align: center"]14[/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: center"]15[/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: center"]16[/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: center"]17[/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: center"]18[/TD]
[TD="align: right"]11/18/1999[/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
</tbody>
Sheet18
[TABLE="width: 85%"]
<tbody>[TR]
[TD]
Array Formulas[TABLE="width: 100%"]
<thead>[TR="bgcolor: #DAE7F5"]
[TH="width: 10px"]Cell[/TH]
[TH="align: left"]Formula[/TH]
[/TR]
</thead><tbody>[TR]
[TH="width: 10px, bgcolor: #DAE7F5"]D18[/TH]
[TD="align: left"]{=SMALL(
IF($A$2:$A$13=TRANSPOSE($A$2:$A$13),IF($B$2:$B$13=C18,IF($C$2:$C$13="C",IF(TRANSPOSE($B$2:$B$13)=B18,IF(TRANSPOSE($C$2:$C$13)="P",IF($D$2:$D$13<TRANSPOSE($D$2:$D$13),IF(ISNUMBER($D$2:$D$13),IF(ISNUMBER(TRANSPOSE($D$2:$D$13)),$D$2:$D$13)))))))),1)}[/TD]
[/TR]
[TR]
[TH="width: 10px, bgcolor: #DAE7F5"]A18[/TH]
[TD="align: left"]{=INDEX(
$A$2:$A$13,SMALL(IF($D$2:$D$13=D18,IF(COUNTIFS($A$2:$A$13,$A$2:$A$13,$B$2:$B$13,B18,$C$2:$C$13,"P")+COUNTIFS($A$2:$A$13,$A$2:$A$13,$B$2:$B$13,C18,$C$2:$C$13,"C"),ROW($A$2:$A$13)-ROW($A$2)+1)),1))}[/TD]
[/TR]
[TR]
[TH="width: 10px, bgcolor: #DAE7F5"]E2[/TH]
[TD="align: left"]{=IF(
MIN(IF((A2=$A$2:$A$13)*($B$2:$B$13=$C$18)*($C$2:$C$13="C")*ISNUMBER($D$2:$D$13),$D$2:$D$13,2^99))<MAX(IF((A2=$A$2:$A$13)*($B$2:$B$13=$B$18)*($C$2:$C$13="P")*ISNUMBER($D$2:$D$13),$D$2:$D$13,0)),1,0)}[/TD]
[/TR]
[TR]
[TH="width: 10px, bgcolor: #DAE7F5"]F2[/TH]
[TD="align: left"]{=SMALL(
IF((E2:E13=1)*(B2:B13=C18)*(C2:C13="C"),D2:D13),1)}[/TD]
[/TR]
</tbody>[/TABLE]
Entered with Ctrl+Shift+Enter. If entered correctly, Excel will surround with curly braces {}.
Note: Do not try and enter the {} manually yourself[/TD]
[/TR]
</tbody>[/TABLE]
Quite a complicated formula in D18. You can see all of the conditions in it, but when to use TRANSPOSE is a bit hard to explain. The formula in A18 is not guaranteed to find the right project, in case of duplicate dates. But it will only match on projects consuming a computer and producing a car. The requirement for the production date being after the consumed date is not included.
Special-K99 has a point, a helper column might be easier to use. I created a helper column in E2 (which you then drag down), which creates a 1 if the project fulfills all the requirements. Then the shorted formula in F2 gets the date, and the A18 formula would work the same.
Hope this helps!
Edit: Based on a later post I now see, I understand why the helper column may not work for you. Try the D18 formula and let us know.