deloptis
asked on
How can I calculate percentage value +ve/-ve growth between 2 values when one or both are negative?
Hi,
I am trying to calculate the % increase / decrease between profit figures from previous to current year. Currently my formula is as follows:
If Sum ({@Current}) <> 0 and Sum ({@Previous}) <> 0 Then
((Sum ({@Current) - Sum ({@Previous}) / Sum ({@Previous})) * 100
It is fine if the current & previous years are both positive or if the previous year is positive and current is negative.
If however the previous year is negative then the values are correct but are incorrectly shown as +ve or -ve percentages (dependant upon current year figure)
I simply want to show a positive % if there has been an increase or a negative % if there has been a decrease, regardless of whether one or both figures are negative. So an example
Previous Year = -200
Current Year = 0
Increase = 100%
Does anyone know how to do this in Crystal?
Thanks in advance!!
I am trying to calculate the % increase / decrease between profit figures from previous to current year. Currently my formula is as follows:
If Sum ({@Current}) <> 0 and Sum ({@Previous}) <> 0 Then
((Sum ({@Current) - Sum ({@Previous}) / Sum ({@Previous})) * 100
It is fine if the current & previous years are both positive or if the previous year is positive and current is negative.
If however the previous year is negative then the values are correct but are incorrectly shown as +ve or -ve percentages (dependant upon current year figure)
I simply want to show a positive % if there has been an increase or a negative % if there has been a decrease, regardless of whether one or both figures are negative. So an example
Previous Year = -200
Current Year = 0
Increase = 100%
Does anyone know how to do this in Crystal?
Thanks in advance!!
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Hi - I stripped down the formula to make it easier to read - but must have backfired on me. Actual formula as below:
If Sum ({@Current }, {orders_by_week.weekno}) <> 0 and Sum ({@Previous}, {orders_by_week.weekno}) <> 0 Then
((Sum ({@Current}, {orders_by_week.weekno}) - Sum ({@Previous}, {orders_by_week.weekno})) / Sum ({@Previous}, {orders_by_week.weekno})) * 100
If Sum ({@Current }, {orders_by_week.weekno}) <> 0 and Sum ({@Previous}, {orders_by_week.weekno}) <> 0 Then
((Sum ({@Current}, {orders_by_week.weekno}) - Sum ({@Previous}, {orders_by_week.weekno})) / Sum ({@Previous}, {orders_by_week.weekno})) * 100
"aburr, go ahead and count the number of right ")" and left "(" parentheses. On the second line of code there are five left parentheses "(", and there are only four right parentheses ")"
-
you are right.
Nevertheless I believe my solution to the problem stands.
-
you are right.
Nevertheless I believe my solution to the problem stands.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
I'll label each one for you. o=open, c=close.
([1o]([2o]Sum([3o]{@Curren