Calculate estimate revenue per period with zeros in between

17 Views Asked by At

I'm trying to do the maths to calculate the estimate revenue for a given period (day, week, month, year)

So for example, if I have data for 30 days, I need to estimate what would be my income tomorrow.

At the moment what I'm doing is quite simple:

  • Calculate growth rate per day for the past 7 days
  • Do the average of each of those rates (for example, 20%)
  • Now apply that growth rate to the previous day

The problem I'm having is having to deals with days where revenue is 0.

I can't calculate the growth rate for it. The way I'm doing it now is:

growth rate = ((day - previous_day) / previous_day) * 100

So I definitely can't divide by 0 if any previous day has $0 revenue. And it also wouldn't make sense to say my growth rate is 100% is one day it goes from 0 to 1.

What should I do in these cases?

Perhaps ignore those previous days and not taking them to account for the growth rate calculation? Should I also ignore any day which value is also 0?

Right now I'm ignoring it, but then I get things like this:

Array
(
    [0] => 0
    [1] => 0
    [2] => 0
    [3] => 259.39
    [4] => 259.39  //estimated
)

Which do not look right at all.