Solved

ACCESS: Need to show a Performance Measure listing that is limited to only the latest data entered.

Posted on 2013-12-12
9
442 Views
Last Modified: 2013-12-16
I have an ACCESS query that joins two tables.  -One to many-  The many is a history table of the dated data collected related to the listed Performance Measures in the 1st table.*
On the many table I have two+ entries of the same record (MsrCd –unique to each Measure- with 2+ different dates.
I  want the report to show me, along with other descriptive info from the 1st table,  just the latest date for every MsrCd.
I have been trying various syntax’ without success:
Ie:    Max( [MsrCd] ! {Entry Date]  )

*-Generated is a report listing of over a hundred Performance Measures showing the Target amount, the data input for a specific date and the resulting Status for that Measure.
The list is showing the same Measure more than once for each new data entry.  I want it to show each Measure only once – the once being the latest MsrCd' data entered.
Eventually, I have to show the latest data entered in each quarter.
0
Comment
Question by:willjx
  • 5
  • 4
9 Comments
 
LVL 39

Expert Comment

by:als315
ID: 39714835
You need 2 queries:
In first (only MsrCd and Entry Date fields) - select max Entry date and group by MsrCd
In second - join your table and first query by MsCd and Entry Date
0
 

Author Comment

by:willjx
ID: 39715533
Did not work:
"In first (only MsrCd and Entry Date fields) - select max Entry date and group by MsrCd"
This did Work to limit to only one MsrCd,
However, when I included this query with the other query that had MeasureDesc linked to TmsrAmt (the history table), it still kept showing the old MsrCd and the new MsrCd.
--disregarding various cardinality changes.
0
 
LVL 39

Expert Comment

by:als315
ID: 39715744
"This did Work to limit to only one MsrCd" - no, you will have 2 columns: one with MsrCd, Second - with Max([Entry Date]) and each MsrCd will have own maximal Enrtry Date.

May be you can prepare sample DB with dummy data?
0
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.

 

Author Comment

by:willjx
ID: 39717456
The query you supplied did limit to the single latest MsrCd and Max([Entry date]) with each MsrCd having its own maximal Enrtry Date.
That is not the issue.
The problem occurs when I take the above query and I join it to the history table, the result goes back to displaying the old and the new MsrCd, when i want it to just display the new MsrCd.
0
 
LVL 39

Expert Comment

by:als315
ID: 39717489
Upload sample DB and show expected result
0
 

Author Comment

by:willjx
ID: 39717890
SELECT Data.Level, Data.Programs, Data.Measure, TmsrAmt.MsrCd, TmsrAmt.Target, IIf(([Do we want to see an increase in this Measure?]=True And ([Data]-[TmsrAmt]![Target])/[TmsrAmt]![Target]>=0) Or ([Do we want to see an increase in this Measure?]=False And ([Data]-[TmsrAmt]![Target])/[TmsrAmt]![Target]<=0),"Green",IIf(([Do we want to see an increase in this Measure?]=True And ([Data]-[TmsrAmt]![Target])/[TmsrAmt]![Target]>=-0.1) Or ([Do we want to see an increase in this Measure?]=False And ([Data]-[TmsrAmt]![Target])/[TmsrAmt]![Target]<=0.1),"Yellow",IIf(([Do we want to see an increase in this Measure?]=True And ([Data]-[TmsrAmt]![Target])/[TmsrAmt]![Target]<-0.1) Or ([Do we want to see an increase in this Measure?]=False And ([Data]-[TmsrAmt]![Target])/[TmsrAmt]![Target]>0.1),"Red","Blue"))) AS Status, TmsrAmt.Data, Data.[Outcome Owner], TmsrAmt.[Data Source], Data.[Key Insights], Data.[Next Action], Max(QpmStatusProgramSpcfkGrp.[MaxOfEntry Date]) AS [MaxOfMaxOfEntry Date]
FROM (Data INNER JOIN QpmStatusProgramSpcfkGrp ON Data.MsrCd = QpmStatusProgramSpcfkGrp.MsrCd) INNER JOIN TmsrAmt ON QpmStatusProgramSpcfkGrp.MsrCd = TmsrAmt.MsrCd
GROUP BY Data.Level, Data.Programs, Data.Measure, TmsrAmt.MsrCd, TmsrAmt.Target, IIf(([Do we want to see an increase in this Measure?]=True And ([Data]-[TmsrAmt]![Target])/[TmsrAmt]![Target]>=0) Or ([Do we want to see an increase in this Measure?]=False And ([Data]-[TmsrAmt]![Target])/[TmsrAmt]![Target]<=0),"Green",IIf(([Do we want to see an increase in this Measure?]=True And ([Data]-[TmsrAmt]![Target])/[TmsrAmt]![Target]>=-0.1) Or ([Do we want to see an increase in this Measure?]=False And ([Data]-[TmsrAmt]![Target])/[TmsrAmt]![Target]<=0.1),"Yellow",IIf(([Do we want to see an increase in this Measure?]=True And ([Data]-[TmsrAmt]![Target])/[TmsrAmt]![Target]<-0.1) Or ([Do we want to see an increase in this Measure?]=False And ([Data]-[TmsrAmt]![Target])/[TmsrAmt]![Target]>0.1),"Red","Blue"))), TmsrAmt.Data, Data.[Outcome Owner], TmsrAmt.[Data Source], Data.[Key Insights], Data.[Next Action]
HAVING (((Data.Level)="program") AND ((Data.Programs) Like [Type 1st couple of letters of the spcfk Program] & "*"));
0
 

Author Comment

by:willjx
ID: 39717910
More simply stated SQL  where QpmStatusProgramSpcfkGrp is the initial Query " (only MsrCd and Entry Date fields) - select max Entry date and group by MsrCd"


SELECT TmsrAmt.MsrCd, TmsrAmt.Data, TmsrAmt.Target, QpmStatusProgramSpcfkGrp.[MaxOfEntry Date]
FROM TmsrAmt INNER JOIN QpmStatusProgramSpcfkGrp ON TmsrAmt.MsrCd = QpmStatusProgramSpcfkGrp.MsrCd
GROUP BY TmsrAmt.MsrCd, TmsrAmt.Data, TmsrAmt.Target, QpmStatusProgramSpcfkGrp.[MaxOfEntry Date];

I expect to see a list of the "SELECT fields, but displaying only the last entry for a given MsrCd.
0
 
LVL 39

Accepted Solution

by:
als315 earned 500 total points
ID: 39718645
"join your table and first query by MsrCd and Entry Date"
You should join both fields from QpmStatusProgramSpcfkGrp: MsrCd and Entry Date (QpmStatusProgramSpcfkGrp.[MaxOfEntry Date]) and should not use max again
0
 

Author Closing Comment

by:willjx
ID: 39722222
Thanks much.
I finally got it, that I needed to join both MsrCd and Entry Date
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

This article describes how to use the timestamp of existing data in a database to allow Tableau to calculate the prior work day instead of relying on case statements or if statements to calculate the days of the week.
Phishing attempts can come in all forms, shapes and sizes. No matter how familiar you think you are with them, always remember to take extra precaution when opening an email with attachments or links.
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…

809 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