Link to home
Start Free TrialLog in
Avatar of Sixpach71
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
Avatar of jrb1
jrb1
Flag of United States of America image

What kind of data?  And what database? In Oracle, this will work...should be similar in other DBs.

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,-12),'yyyy')
ASKER CERTIFIED SOLUTION
Avatar of Guy Hengel [angelIII / a3]
Guy Hengel [angelIII / a3]
Flag of Luxembourg image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Sixpach71
Sixpach71

ASKER

I'm using a DB2 db on an iSeries server.  Will look at the suggestions given and post back.  

Thanks,

H
angelIII,

Your suggestion got me on the right track.  I did some tweaking and was able to obtain the right data.  

Thanks!

H