How can I automatically split values over specified time periods?

G

Grushenka

Hi, I monitor the energy usage for my organisation and report quarterly. As
you will be aware, utility bills do not always come in nice and neat
quarterly or monthly invoicing periods and I would really benefit from a way
of automatically splitting amounts entered into quarters. e.g

I enter 25 Dec 07 to 04 Feb 08 = 1000 kwh

Rather than manually dividing myself, can I allocate 5 days usage to the Oct
to Dec quarter and the rest to the Jan to Mar quarter?

Any help would be greatly appreciated :)
 
S

Sam Wilson

Hi,

I had to do something similar, this was the fastest technique:

Let A & B be your quarter start and end date, X & Y the period covered on
the electricity bill. You want to work out the overlap between these two
periods (you can do the same for the next quarter after AB etc)

The biggest the overlap can be is: A+1-B days (if A and B are the same it's
1 day, hence the +1) So, so far =(A+1-B)

If the bill period ends before the quarter period then you need to knock
theses days off. This is Max(B-Y,0), so we have =(A+1-B) - Max(B-Y,0)

If the bill period starts after the quarter period then you need to knock
these days off, this is Max(X-A,0)... This gives
=(A+1-B)-Max(B-Y,0)-Max(X-A,0)


As a final point, the whole lot must be at least 0 days, so this must be the
final formula:

=Max((A+1-B)-Max(B-Y,0)-Max(X-A,0),0)

I hope that makes sense...
 
G

Grushenka

Thanks Sam! :)

Sam Wilson said:
Hi,

I had to do something similar, this was the fastest technique:

Let A & B be your quarter start and end date, X & Y the period covered on
the electricity bill. You want to work out the overlap between these two
periods (you can do the same for the next quarter after AB etc)

The biggest the overlap can be is: A+1-B days (if A and B are the same it's
1 day, hence the +1) So, so far =(A+1-B)

If the bill period ends before the quarter period then you need to knock
theses days off. This is Max(B-Y,0), so we have =(A+1-B) - Max(B-Y,0)

If the bill period starts after the quarter period then you need to knock
these days off, this is Max(X-A,0)... This gives
=(A+1-B)-Max(B-Y,0)-Max(X-A,0)


As a final point, the whole lot must be at least 0 days, so this must be the
final formula:

=Max((A+1-B)-Max(B-Y,0)-Max(X-A,0),0)

I hope that makes sense...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top