Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

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

Posted on 2010-11-10
10
Medium Priority
?
424 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 400 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 400 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
Free learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

 
LVL 13

Accepted Solution

by:
gbanik earned 800 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:Tracy
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:Tracy
Tracy earned 400 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
If you need to forecast numbers -- typically for finance -- the Windows and Mac versions of Excel 2016 have a basket of tools to get the job done.
This Micro Tutorial will demonstrate in Google Sheets how to use the HYPERLINK function to create live links inside your spreadsheet.
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa‚Ķ

824 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