Solved

How do I detect the latest record of same ID in Access or Excel?

Posted on 2010-11-10
10
414 Views
Last Modified: 2012-05-10
I have a spreadsheet storing data and I plan to use Access to do data sorting
In the table, i have customer ID and  date field. where ID is not unique. say,
CustID       date
0001        10/1/2010
002          01/09/2009
0001        08/01/2006

how could I identify the latest record of same customer?
0
Comment
Question by:hkgal
  • 2
  • 2
  • 2
  • +3
10 Comments
 
LVL 120

Assisted Solution

by:Rey Obrero (Capricorn1)
Rey Obrero (Capricorn1) earned 100 total points
ID: 34101529

to identify

select * from tablex
where [date]=(select max([date]) from tablex as T where CustID=tablex.custID)

to delete

delete * from tablex
where [date]=(select max([date]) from tablex as T where CustID=tablex.custID)
0
 
LVL 61

Assisted Solution

by:mbizup
mbizup earned 100 total points
ID: 34101535
hkgal,

Assuming you have a linked or imported table:

SELECT CustID, Max([Date])
FROM YourTable
GROUP BY CustID
0
 
LVL 61

Expert Comment

by:mbizup
ID: 34101555
You should also consider renaming your Date field to something like SalesDate (or whatever), since Date is a reserved word in Access.
0
Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

 
LVL 13

Accepted Solution

by:
gbanik earned 200 total points
ID: 34101643
In Excel i can tell you... in order to find out the last date for an ID use the following array formula
=MAX(IF(A:A=A2,B:B))
In the attached example I have added 2 columkns for you to try out... 1st column says whether the current date is the last date for that ID, the 2nd column gives you the last date of that ID.
Max-Date.xlsx
0
 
LVL 24

Expert Comment

by:StephenJR
ID: 34101656
In Excel you could also do a pivot table, using max date as the data field.
0
 

Author Comment

by:hkgal
ID: 34101769
gbanik...sorry cannot open the file..
0
 
LVL 13

Expert Comment

by:gbanik
ID: 34101930
This is a 2007 version that I attached. What version r u using?

Meanwhile I downloaded that file and checked .. for 2007 it works!
0
 

Author Comment

by:hkgal
ID: 34101935
2003...
0
 
LVL 24

Expert Comment

by:broomee9
ID: 34102056
NFP

For Excel 2003, I modified gbanik's formula a little and expanded the dataset.  See attached.

=MAX(IF($A$2:$A$7=A2,$B$2:$B$7))

Book1.xls
0
 
LVL 24

Assisted Solution

by:broomee9
broomee9 earned 100 total points
ID: 34102067
Please note that the formula above is an array formula and should be entered with Ctrl + Shift + Enter.  This will add the {} around the formula.  The end result should be:

{=MAX(IF($A$2:$A$7=A2,$B$2:$B$7))}
0

Featured Post

Back Up Your Microsoft Windows Server®

Back up all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Excel error  #DIV/0! 7 18
Clear Filter 8 39
2 IIF's in Access query 25 26
Excel VBA Select non contiguous cells in a loop 4 28
Introduction This Article briefly covers methods of calculating the NPV and IRR variants in Excel as well as the limitations in calculating and interpreting IRR results. Paraphrasing Richard Shockley, author of my favourite finance reference tex…
When you see single cell contains number and text, and you have to get any date out of it seems like cracking our heads.
This Micro Tutorial will demonstrate in Microsoft Excel how to add style and sexy appeal to horizontal bar charts.
This Micro Tutorial will demonstrate how to use a scrolling table in Microsoft Excel using the INDEX function.

773 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question