Solved

How can I compare two month totals and show those that are 10% lower than previous month?

Posted on 2014-09-15
3
123 Views
Last Modified: 2014-09-17
The attached query lists each month totals for Cntr.  I want the query to show only months that the Cntr totals were 10% lower than previous month's.
qryComparisonYTD.docx
0
Comment
Question by:softsupport
  • 2
3 Comments
 
LVL 24

Expert Comment

by:chaau
ID: 40324405
can you please show some sample data. It is unclear what values are in your qryClaimComparisonYTD.[ClaimDate] column for each row
0
 

Author Comment

by:softsupport
ID: 40325674
Sample data attached.  Query lists total for each month.  I want to compare current months totals to the previous month and show if totals are 10% lower.
dataComparisonYTD.xlsx
0
 
LVL 24

Accepted Solution

by:
chaau earned 500 total points
ID: 40326904
Thanks for the sample data. It really helped. This query will give you the desired result:
SELECT Prev.[Center_Center Id], Prev.[Center Name], 
Prev.[CenterClaim_Center Id], Prev.ClaimDate, 
Prev.CenterTotalClaimed, Curr.ClaimDate, 
Curr.CenterTotalClaimed
FROM qryMealsClaimComparisonYTD AS Prev INNER JOIN qryMealsClaimComparisonYTD AS Curr 
ON (Prev.[CenterClaim_Center Id] = Curr.[CenterClaim_Center Id]) AND (Prev.[Center_Center Id] = Curr.[Center_Center Id])
WHERE ((([Prev].[ClaimDate]+1)=DateAdd("m",-1,[Curr].[ClaimDate]+1)) AND ((Curr.CenterTotalClaimed)<=[Prev].[CenterTotalClaimed]*0.9));

Open in new window

You can adjust the percentage by modifying the last parameter "[CenterTotalClaimed]*0.9". At the moment it is "*0.9" but you can make it 0.8 for 20%
This is the results of this query:
Query Result
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Experts-Exchange is a great place to come for help with solutions for your database issues, and many problems are resolved within minutes of being posted.  Others take a little more time and effort and often providing a sample database is very helpf…
I see at least one EE question a week that pertains to using temporary tables in MS Access.  But surprisingly, I was unable to find a single article devoted solely to this topic. I don’t intend to describe all of the uses of temporary tables in t…
Familiarize people with the process of utilizing SQL Server stored procedures from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Micr…
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…

911 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now