Hi, I am creating a report which needs to calculate the %change from the previous month. I have tried using a nested query which tries to take the value from the previous month and then the current month to get the % change. The issue is the output is in the wrong place. Any help will be much appreciated.
Thank you -
SELECT [Data Research].[Date of Request] AS [Month], [Data Research].[Number of Requests] AS [Total Requests], [Data Research].[Number of Items Requested] AS [Total Items], [Data Research].[Number added to DCS] AS [Items Found], Format(([Number added to DCS]/[Number of Items Requested])*100,"Fixed") AS [% Found], [Data Research].[DCS Assigned] AS [Number Migrated], [Data Research].[DCS Backlog] AS Backlog, Format(((((Select [Data Research].[DCS Backlog] FROM [Data Research] WHERE Year([Date of Request])* 12 + DatePart("m", [Date of Request]) = Year(Date())* 12 + DatePart("m", Date()) - 1)/[Data Research].[DCS Backlog])-1)*100), "fixed") AS [Backlog % increase/decrease]
-
FROM [Data Research];
-
5 8481
What do you mean the output is in the wrong place? Just change the place.
For example, I want to calculate the %change from jan to feb, this should go in the feb record, but the way the above query works, it puts the answer in the jan record
Can you post some sample data and the expected results?
Sorry for the delay in replying Rabbit, been put on other projects by management, but now they want me to finish off this one.
Back to your question
Data looks like this -
Date of Request Number of Requests Number of Items Requested Number added to DCS DCS Backlog DCS Assigned Requests added to wishlist
-
2010/06 12 45 14
-
2010/07 20 42 18
-
2010/08 21 24 10
-
2010/09 31 41 14
-
2010/10 24 40 14 45 12
-
2010/11 46 80 20 37 28 12
-
2010/12 16 28 15 41 10 10
-
2011/01 30 61 10 35 17 11
-
2011/02 18 24 10 23 21 12
-
I need the output to look like this -
Month Total Requests Total Items Items Found % Found Number Migrated Backlog Backlog % increase/decrease
-
2011/01 30 61 10 16.39 17 35
-
2011/02 18 24 10 41.67 21 23
-
The Backlog% will be the % difference from Jan to Feb, in the Feb row.
I hope that makes sense, and thank you for your help.
You'll need to use a subquery to return the prior month's backlog so that you can use it in the calculation. Assuming the formula you're using is (CurrentRowBacklog - PriorMonthBacklog) / PriorMonthBacklog , you will need to use the subquery twice to return the prior month's backlog.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: eddie wang |
last post by:
How to convert a month to previous month in a very easy way? For
example, I have AUGUST, but I want JULY to return.
Thanks.
*** Sent via Developersdex http://www.developersdex.com ***
Don't...
|
by: Killer |
last post by:
How can i calculate the last day of the previous month?
Help me,please
|
by: Ray via SQLMonster.com |
last post by:
Hi there,
See if you can help me with the following:
I need to write an SQL code that will return me:
The 1st day & the Last day of the Previous Month in the following format...
|
by: Finlay |
last post by:
Hi Group
I am designing a report that should show a meter reading for each
month and the previous meter reading for the previous month. The
months are text stored in a field tMonth.
The...
|
by: tulikapuri |
last post by:
Dear Friends,
I am using the method to cal. percentage in report but no sucess it gives #Num! instead of a number. I am following the steps as given in help to calculate percentage value on a...
|
by: TB |
last post by:
HI, is there a formula(function) you could use to the display the
previous month's name in a report. i know there is a
function(formula) that returns the previous month's value (ie 4 for
the...
|
by: Massimo30 |
last post by:
Looking for answers and have done a search in books and websites and still can't find the answer:
I am setting up a Market Trend DB on housing figures. I have the following fields in my table:
My...
|
by: marlberg |
last post by:
Platform: Windows2000, WindowsXP, Windows Vista, etc
Language: C#, ASP.NET
Pre-compiled Libraries: Enterprise Library 3.0 full
I have a requirement to implement in and display in C# and...
|
by: yappy77 |
last post by:
I have a query that I need help in writing the expression to calculate the first of the month following the end of previous month.
Example:
Policy expiration date = between 2/1/11 and 2/28/11...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
| |