Formula to search max. value based on criteria in other column

roelandwatteeuw

Board Regular
Joined
Feb 20, 2015
Messages
87
Office Version
  1. 365
Platform
  1. Windows
Hi all

I have this data with columns:
- A: the ID of the product
- B: the start of the proces
- C: the end of te proces
- D: the state of the proces during B to C

IDStartEndState
10028700​
1/01/2020​
31/03/2021​
Active
10028700​
1/04/2021​
31/12/9999​
Inactive
10029917​
1/07/2021​
30/09/2021​
Active
10029917​
1/10/2021​
31/12/9999​
Active
10030325​
1/10/2019​
2/03/2021​
Active
10030325​
1/04/2022​
31/12/9999​
Inactive
10031873​
1/09/2021​
3/10/2021​
Inactive
10031873​
4/10/2021​
14/11/2021​
Active
10031873​
15/11/2021​
31/01/2022​
Active
10031873
01/02/2022​
31/12/9999​
Active

What do I need:

A formula where Excel first looks at all the same ID's (A).
For those ID's I need the State (D) of the last End date (C) within all the rows with this ID.

This what it should look like:

IDStartEndStateLast state
10028700
1/01/2020​
31/03/2021​
ActiveInactive
10028700
1/04/2021​
31/12/9999
InactiveInactive
10029917
1/07/2021​
30/09/2021​
InactiveActive
10029917
1/10/2021​
31/12/9999
ActiveActive
10030325
1/04/2022​
31/12/2025
ActiveActive
10030325
1/10/2019​
31/03/2022​
InactiveActive
10031873
1/09/2021​
3/10/2021​
InactiveActive
10031873
4/10/2021​
14/11/2021​
ActiveActive
10031873
15/11/2021​
31/01/2022​
ActiveActive
10031873
01/02/2022​
31/12/9999
ActiveActive

Hope you can help me!


gr.
Roely
 
And found a solution for the dynamic range:

Excel Formula:
=INDEX(SORT(FILTER($B$2:    INDIRECT(CONCATENATE("D",$L$1))     ,$A$2:   INDIRECT(CONCATENATE("A",$L$1))   =A2),1,-1),1,3)
And L1 =
Excel Formula:
=match(2,1/(D:D<>""),1)
 
Upvote 0

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple
That is volatile & will calculate if you so much as breathe.
You would be better off with something like
Excel Formula:
=LET(rw,LOOKUP(2,1/(A:A<>""),ROW(A:A)),INDEX(SORT(FILTER(INDEX(B:B,2):INDEX($D:$D,rw),$A$2:INDEX($A:$A,rw)=A2),1,-1),1,3))
 
Upvote 0
That is volatile & will calculate if you so much as breathe.
You would be better off with something like
Excel Formula:
=LET(rw,LOOKUP(2,1/(A:A<>""),ROW(A:A)),INDEX(SORT(FILTER(INDEX(B:B,2):INDEX($D:$D,rw),$A$2:INDEX($A:$A,rw)=A2),1,-1),1,3))
Works great as well. ??
Didn't know the 'LET-function'. Definitely will be handy in the Future!
 
Upvote 0

Forum statistics

Threads
1,223,234
Messages
6,170,891
Members
452,366
Latest member
TePunaBloke

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