Sixpach71
asked on
Formula for calculating % of growth or decline
I need to be able to determine the percent of growth or decline from one year to the next. I have a group based on year and a summary field for the figure that I am totaling. How do I get the totals from the current year and previous year to perform the following calculation: sum of current year figure - sum of previous year figure / sum of previous year figure
Thanks,
H
Thanks,
H
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I'm using a DB2 db on an iSeries server. Will look at the suggestions given and post back.
Thanks,
H
Thanks,
H
ASKER
angelIII,
Your suggestion got me on the right track. I did some tweaking and was able to obtain the right data.
Thanks!
H
Your suggestion got me on the right track. I did some tweaking and was able to obtain the right data.
Thanks!
H
key date amount
a1 1/1/2004 100
a2 1/2/2004 200
b1 1/1/2005 500
b2 3/1/2005 50
You could:
select (sum(a.amount) - sum(b.amount)) / sum(b.amount) * 100
from yourtable a
, yourtable b
where to_char(a.date,'yyyy') = to_char(sysdate,'yyyy')
and to_char(b.date,'yyyy') = to_char(add_months(sysdate