Search code examples
excelsortingfilterformula

Excel formula - extract IDs for a specific year - and no previous years


I have a sheet with +100 000 records It is just a product ID and a Year

I need to extract the IDs that have the year 2019 only - and no earlier year than that. So in the image below I just want to get line 9 and 10. For example, Product ID 4488, has year 2013,2012,2010 so those I want to exclude.

I have tried some conditional formulas but I dont get the result I want

enter image description here


Solution

  • If all entries are unique (same ID with same year not repeated). You could use something like this =IF(AND(COUNTIF(A:A,A2)=1,B2=2019),A2,"") in C2 and doubleclick or drag down.

    COUNTIF finds how many times ID appears in a list (obviously more than one time would mean that there are multiple years). So rest of formula checks if ID appeared only one time and is year 2019. Result:

    enter image description here