SOLVED

Eliminate multiple older dates from a spreadsheet

%3CLINGO-SUB%20id%3D%22lingo-sub-2388173%22%20slang%3D%22en-US%22%3EEliminate%20multiple%20older%20dates%20from%20a%20spreadsheet%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2388173%22%20slang%3D%22en-US%22%3E%3CP%3EMy%20sheet%20has%20ID%20numbers%20in%20Column%20A%20and%20dates%20in%20Column%20B.%26nbsp%3B%20When%20there%20is%20more%20than%20one%20date%20for%20an%20ID%20number%2C%20the%20ID%20number%20is%20repeated%20in%20Column%20A%20with%20a%20different%20date%20each%20time%20in%20Column%20B.%26nbsp%3B%20(Some%20ID%20numbers%20have%20only%20one%20date%2C%20but%20most%20have%20two%20or%20many%20dates.)%26nbsp%3B%20I%20want%20only%20the%20latest%20date%20for%20each%20ID%20number.%26nbsp%3B%20Is%20there%20a%20way%20to%20do%20this%20in%20Excel%3F%26nbsp%3B%20Thanks%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-2388173%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EExcel%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2388335%22%20slang%3D%22en-US%22%3ERe%3A%20Eliminate%20multiple%20older%20dates%20from%20a%20spreadsheet%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2388335%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F777144%22%20target%3D%22_blank%22%3E%40Tracy7212%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EYes.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EBut%20that%20isn't%20really%20a%20sufficient%20answer%2C%20since%20there%20are%20other%20questions%20that%20would%20need%20to%20be%20asked%20of%20you%20and%20your%20spreadsheet.%20Is%20it%20possible%20for%20you%20to%20post%20a%20copy%20of%20the%20spreadsheet%20(so%20long%20as%20there's%20no%20confidential%20info)%3F%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EFor%20example%2C%20since%20there%20are%20for%20many%20IDs%2C%20many%20rows%20with%20multiple%20dates%2C%20and%20you%20only%20want%20the%20latest%20date%20for%20each%20ID%2C%20does%20that%20mean%3C%2FP%3E%3CUL%3E%3CLI%3Eyou%20just%20want%20to%20see%20what%20the%20latest%20date%20is%20for%20any%20given%20ID%3F%3C%2FLI%3E%3CLI%3Eyou%20want%20to%20eliminate%20the%20rows%20that%20have%20earlier%20dates%3F%3C%2FLI%3E%3CLI%3Eyou%20want%20all%20the%20earlier%20dates%20replaced%20by%20the%20latest%20date%3F%3C%2FLI%3E%3CLI%3Eyou%20want%20to%20place%20blanks%20where%20there%20were%20earlier%20dates%3F%3C%2FLI%3E%3C%2FUL%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EAnd%2C%20frankly%2C%20as%20a%20person%20who%20during%20my%20working%20career%20(retired%20now)%20had%20responsibility%20for%20a%20major%20corporation's%20HR%20database%2C%20I%20know%20that%20there%20can%20be%20real%20value--in%20some%20cases%20essential--in%20retaining%20history%20of%20events%20or%20transactions.%20For%20what%20it's%20worth%2C%20the%20latest%20date%20for%20any%20given%20ID%20can%20always%20be%20ascertained%20with%20judicious%20use%20of%20the%20MAX%20function.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2388390%22%20slang%3D%22en-US%22%3ERe%3A%20Eliminate%20multiple%20older%20dates%20from%20a%20spreadsheet%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2388390%22%20slang%3D%22en-US%22%3EGood%20questions!%20I'm%20making%20a%20simple%20cheat-sheet%20of%20data%20queried%20from%20a%20proprietary%20database%20(unfortunately%20I%20couldn't%20accomplish%20this%20within%20the%20DB)%20so%20there%20is%20no%20worry%20of%20loss%20of%20historical%20data.%20I%20want%20the%20ID%20number%20in%20Column%20A%20to%20appear%20only%20once%2C%20with%20its%20most%20recent%20date%20in%20Column%20B.%20I'll%20post%20an%20abbreviated%20version%3A%20Columns%20A%20%26amp%3B%20B%20is%20the%20dataset%2C%20Columns%20D%20%26amp%3B%20E%20show%20blank%20rows%20where%20the%20eliminated%20data%20were%2C%20and%20Columns%20G%20%26amp%3B%20H%20is%20the%20same%2C%20with%20the%20blank%20rows%20removed.%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2388396%22%20slang%3D%22en-US%22%3ERe%3A%20Eliminate%20multiple%20older%20dates%20from%20a%20spreadsheet%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2388396%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F777144%22%20target%3D%22_blank%22%3E%40Tracy7212%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2389061%22%20slang%3D%22en-US%22%3ERe%3A%20Eliminate%20multiple%20older%20dates%20from%20a%20spreadsheet%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2389061%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F777144%22%20target%3D%22_blank%22%3E%40Tracy7212%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EYou%20will%20need%20the%20most%20recent%20release%20of%20Excel%20in%20order%20for%20this%20particular%20solution%20to%20work%2C%20but%20it's%20worth%20getting%20if%20you%20don't%20have%20it.%3C%2FP%3E%3CP%3EI've%20used%20two%20of%20the%20new%20Dynamic%20Array%20functions%20in%20this%20solution%2C%20UNIQUE%20and%20FILTER.%20Down%20below%20I'll%20put%20a%20link%20to%20a%20YouTube%20video%20that%20explains%20the%20functions.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EIn%20cell%20L2%20I%20entered%20this%20formula%3A%20%3CSTRONG%3E%3DSORT(UNIQUE(A2%3AA21))%3C%2FSTRONG%3E%3C%2FP%3E%3CP%3EThat%20formula%2C%20in%20that%20single%20cell%2C%20produced%20the%20list%20of%20unique%20IDs%2C%20sorted%20in%20order.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThen%20in%20Cell%20M2%2C%20I%20entered%20this%20formula%20(and%20then%20copied%20it%20down%20adjacent%20to%20the%20unique%20ID%20list%3A%3C%2FP%3E%3CP%3E%3CSTRONG%3E%3DMAX(FILTER(%24B%242%3A%24B%2421%2C%24A%242%3A%24A%2421%3DL2))%3C%2FSTRONG%3E%3C%2FP%3E%3CP%3EWhich%2C%20first%2C%20by%20means%20of%20the%20FILTER%20function%2C%20gets%20all%20of%20the%20dates%20associated%20with%20whatever%20ID%20is%20adjacent%20(L2%20in%20the%20first%20row)%3C%2FP%3E%3CP%3Eand%20then%2C%20by%20means%20of%20MAX%20function%2C%20picks%20only%20the%20greatest%20date.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThe%20result%20is%20exactly%20like%20your%20sample%20showed%20it%20should%20be.%26nbsp%3B%20See%20the%20attached.%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22mathetes_0-1622063433317.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F283993i127E83A56636ED7B%2Fimage-size%2Fmedium%3Fv%3Dv2%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%22mathetes_0-1622063433317.png%22%20alt%3D%22mathetes_0-1622063433317.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3EHere's%20that%20promised%20link%20to%20YouTube%3A%20%3CA%20href%3D%22https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3D9I9DtFOVPIg%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3D9I9DtFOVPIg%3C%2FA%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E
Occasional Contributor

My sheet has ID numbers in Column A and dates in Column B.  When there is more than one date for an ID number, the ID number is repeated in Column A with a different date each time in Column B.  (Some ID numbers have only one date, but most have two or many dates.)  I want only the latest date for each ID number.  Is there a way to do this in Excel?  Thanks

9 Replies

@Tracy7212 

 

Yes.

 

But that isn't really a sufficient answer, since there are other questions that would need to be asked of you and your spreadsheet. Is it possible for you to post a copy of the spreadsheet (so long as there's no confidential info)?

 

For example, since there are for many IDs, many rows with multiple dates, and you only want the latest date for each ID, does that mean

  • you just want to see what the latest date is for any given ID?
  • you want to eliminate the rows that have earlier dates?
  • you want all the earlier dates replaced by the latest date?
  • you want to place blanks where there were earlier dates?

 

And, frankly, as a person who during my working career (retired now) had responsibility for a major corporation's HR database, I know that there can be real value--in some cases essential--in retaining history of events or transactions. For what it's worth, the latest date for any given ID can always be ascertained with judicious use of the MAX function.

Good questions! I'm making a simple cheat-sheet of data queried from a proprietary database (unfortunately I couldn't accomplish this within the DB) so there is no worry of loss of historical data. I want the ID number in Column A to appear only once, with its most recent date in Column B. I'll post an abbreviated version: Columns A & B is the dataset, Columns D & E show blank rows where the eliminated data were, and Columns G & H is the same, with the blank rows removed.
best response confirmed by Tracy7212 (Occasional Contributor)
Solution

@Tracy7212 

 

You will need the most recent release of Excel in order for this particular solution to work, but it's worth getting if you don't have it.

I've used two of the new Dynamic Array functions in this solution, UNIQUE and FILTER. Down below I'll put a link to a YouTube video that explains the functions.

 

In cell L2 I entered this formula: =SORT(UNIQUE(A2:A21))

That formula, in that single cell, produced the list of unique IDs, sorted in order.

 

Then in Cell M2, I entered this formula (and then copied it down adjacent to the unique ID list:

=MAX(FILTER($B$2:$B$21,$A$2:$A$21=L2))

Which, first, by means of the FILTER function, gets all of the dates associated with whatever ID is adjacent (L2 in the first row)

and then, by means of MAX function, picks only the greatest date.

 

The result is exactly like your sample showed it should be.  See the attached.

mathetes_0-1622063433317.png

Here's that promised link to YouTube: https://www.youtube.com/watch?v=9I9DtFOVPIg

 

Learn everything about our brand-new Dynamic Arrays and how you can use them to build advanced spreadsheets. Arrays (CSE) have long been present in Excel, bu...

Thank you SO MUCH for this help.  I wish I knew these more sophisticated functions, and I'm grateful there are folks as yourself willing to lend a hand.  Your guidance was crystal clear, and I haven't even looked at the video yet.  I would just add for anyone else using this technique, at the end, you may need to copy and paste-as-values Columns L & M, and choose a date format for Column M.  

 

My actual spreadsheet had over 3,000 rows, so, again, my great appreciation!  Tracy

@Tracy7212 

An alternative formula?

= LET(
  distinctID, UNIQUE(ID),
  maxDate, MAXIFS(Date, ID, distinctID),
  IF({1,0}, distinctID, maxDate))

Maybe, I'm missing something but...

If you can query the database, the below SQL will give you what you want.  You can also use drag-and-drop in MS Query to get Excel to build the query for you.

select id, max(date_of_interest)
from my_table
group by id

 

@Tracy7212 

@tusharm10 

If that's SQL database better to use Power Query, it generates in background same SQL query using query folding mechanism, no need in native SQL query.

You are very welcome. I discovered those functions only late last year...and they've been great, as you're finding out