Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

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

Posted on 2014-09-15
3
125 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

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Question has a verified solution.

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

In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
It’s been over a month into 2017, and there is already a sophisticated Gmail phishing email making it rounds. New techniques and tactics, have given hackers a way to authentically impersonate your contacts.How it Works The attack works by targeti…
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…
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.

792 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