How to find the earliest or latest date base on criteria in Excel?
Let’s say, you have two columns of data which Column A contains the products, Column B includes date, and now, you want to find the earliest or latest date based on the criteria in Column A as following screenshot shown. How could you solve this problem quickly in Excel?
In Excel, the following array formulas may help you to return the oldest or latest date with criteria, please do as follows:
To get the earliest date based on criteria:
1. Enter this formula: =MIN(IF($A$2:$A$16="Office Tab",$B$2:$B$16)) into a blank cell where you want to get the result, and then press Ctrl + Shift + Enter keys together to return the oldest date based on the criteria – Office Tab of Column A, and you will get a 5 digits number, See screenshot:
Tips: In this formula: A2:A16 is the data range contains the criteria that you based on, “Office Tab” is the criteria that you use, and B2:B16 includes the date that you want to return.
2. Then you should convert the 5 digits number to date format, please click Home, go to General drop down to choose the Short Date format , and the earliest date based on Office Tab has been displayed, see screenshot:
To get the latest date with the criteria, you can apply this array formula: =MAX(IF($A$2:$A$16="Office Tab",$B$2:$B$16)), and remember to press Ctrl + Shift + Enter keys together to get the correct result.
Kutools for Excel’s Advanced Combine Rows feature can help you to get the earliest or latest date of each item in Column A without any formulas.
|Kutools for Excel : with more than 300 handy Excel add-ins, free to try with no limitation in 60 days.|
If you have installed Kutools for Excel, please do as follows:
1. If you want to keep the original data, you can copy and paste the data to another range, and then select the pasted range that you want to use.
2. Then click Kutools > Content > Advanced Combine Rows, see screenshot:
3. In the Combine Rows Based on Column dialog box, please click the column name that you want to get the date based on, and then click Primary Key option, see screenshot:
4. Then click the date column that you want to return the latest or earliest date, and select Calculate > Max / Min, ( select Max to get the latest date and Min to return the oldest date), see screenshot:
Tips: If you check My data has headers, your header within the data range will be ignored automatically, to get the correct date format, please uncheck Use formatted values option.
5. Then click Ok button, the latest or oldest date base on each item has been returned as follows: