To calculate monthly and yearly gas usage between 2 random dates.

Trent10

New Member
Joined
Dec 27, 2012
Messages
3
ABC
DateElectricity (kWh)Gas (kWh)
6/26/10453521747
21/12/10687826787
5/5/11890029001
9/10/111020032901
1/2/121480036980
2/7/121822139001
12/27/121901144012

<tbody>
</tbody>

Hello,
I would like to calculate monthly and yearly gas and electricity consumption between random dates?
The answer might be already there on this forum. In that case, please provide the link to the thread.

I would very much appreciate any help. Thank you in advance.

With regards,

Will
 

Excel Facts

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).
Hello and welcome to MrExcel.

Is this the sort of result you are looking for from the two random dates?.....

Excel Workbook
ABCDEFGHIJKL
1DateElectricity (kWh)Gas (kWh)Electricity (kWh)Gas (kWh)
226/06/2012453521747Date1Date2TotalDate1Date2Total
321/12/201068782678725/12/201006/06/2011890025/12/201006/06/201129001
405/05/2011890029001
510/09/20111020032901
602/01/20121480036980
707/02/20121822139001
827/12/20121901144012
9
Sheet1


I hope this helps.

Ak
 
Last edited:
Upvote 0
Dear AK,
Thank you for your prompt reply.
Would you please explain to me how you worked out the Date1 (E3) and Date 2 (F3)?
one minor correction - the year in cell A2 is 2010.

Is it possible to work out monthly and yearly gas & Electricity consumptions with the data I have provided?

Once again thank you for all your help.

With regards,

Will
 
Upvote 0
Hi Will.

The dates in E3:F3 are just random dates I put in.
This is how I understand what the formula in G3 does...
Are any of the cells in ($A$2:$A$8 Greater than or equal to $E$3)*(Are any of the cells in ($A$2:$A$8 Less than or equal to $F$3)*(get the values from the cells in $B$2:$B$8 where there is a match)).
The first two parts of the formula returns either TRUE or FALSE, the * converts these to 1 or 0.
This is what the formula looks like underneath....
=SUMPRODUCT(({FALSE;FALSE;TRUE;TRUE;TRUE;TRUE;TRUE})*({TRUE;TRUE;TRUE;FALSE;FALSE;FALSE;FALSE})*({4535;6878;8900;10200;14800;18221;19011}))

Hopefully someone else will jump in with a clearer more accurate explanation.

Based on your sample data, can you post the results you would expect to get based on your month criteria and your year criteria?
Do you want the total for both gas and electric or individually as I have posted above?

Ak
 
Upvote 0
Hello and welcome to MrExcel.

Is this the sort of result you are looking for from the two random dates?.....

Sheet1

ABCDEFGHIJKL
1DateElectricity (kWh)Gas (kWh)Electricity (kWh)Gas (kWh)
226/06/2012453521747Date1Date2TotalDate1Date2Total
321/12/201068782678725/12/201006/06/2011890025/12/201006/06/201129001
405/05/2011890029001
510/09/20111020032901
602/01/20121480036980
707/02/20121822139001
827/12/20121901144012
9

<tbody>
</tbody>

Spreadsheet Formulas
CellFormula
G3=SUMPRODUCT(($A$2:$A$8>=$E$3)*($A$2:$A$8<=$F$3)*($B$2:$B$8))
K3=SUMPRODUCT(($A$2:$A$8>=$I$3)*($A$2:$A$8<=$J$3)*($C$2:$C$8))

<tbody>
</tbody>

<tbody>
</tbody>


Excel tables to the web >> Excel Jeanie HTML 4

I hope this helps.

Ak
I believe Trent10 meant something different.
In my opinion the right way to calculate the consumption between the 2 dates is to calculate the daily average consumption between the data of the date before the start date and the date after the end date, and then multiply it in the number of days between the 2 requested dates.
the formula for the electricity G3 is
:
Code:
=(INDEX($B$2:$B$8,MATCH(F3,$A$2:$A$8)+1)-INDEX($B$2:$B$8,MATCH(E3,$A$2:$A$8)))/(INDEX($A$2:$A$8,MATCH(F3,$A$2:$A$8)+1)-INDEX($A$2:$A$8,MATCH(E3,$A$2:$A$8)))*(F3-E3)
the result is 2,059

the formula for the electricity K3 is:
Code:
=(INDEX($C$2:$C$8,MATCH(J3,$A$2:$A$8)+1)-INDEX($C$2:$C$8,MATCH(I3,$A$2:$A$8)))/(INDEX($A$2:$A$8,MATCH(J3,$A$2:$A$8)+1)-INDEX($A$2:$A$8,MATCH(I3,$A$2:$A$8)))*(F3-E3)
the result is 3,789
 
Last edited:
Upvote 0

the formula for the electricity G3 is
:
Code:
=(INDEX($B$2:$B$8,MATCH(F3,$A$2:$A$8)+1)-INDEX($B$2:$B$8,MATCH(E3,$A$2:$A$8)))/(INDEX($A$2:$A$8,MATCH(F3,$A$2:$A$8)+1)-INDEX($A$2:$A$8,MATCH(E3,$A$2:$A$8)))*(F3-E3)
the result is 2,059

the formula for the electricity K3 is:
Code:
=(INDEX($C$2:$C$8,MATCH(J3,$A$2:$A$8)+1)-INDEX($C$2:$C$8,MATCH(I3,$A$2:$A$8)))/(INDEX($A$2:$A$8,MATCH(J3,$A$2:$A$8)+1)-INDEX($A$2:$A$8,MATCH(I3,$A$2:$A$8)))*(F3-E3)
the result is 3,789
To calculate the monthly and yearly consumption replace the (F3-E3) part of the formula with 30.5 for month and 365 for a year
 
Upvote 0
Thanks AK and iyyi.
I have a problem, both your formulas work, but which one is right?
Iyyi's formula returns the value in days and hours in spite of me formatting the cell to number.
 
Upvote 0
Hi.

Thanks for the feedback I'm pleased you have resolved the problem.
If both formulas are working as you required, then I would suggest using the formula that you find the easiest to understand, this way, if you need to change it in the future, you should be able to do so with relative ease.

For iyyi's formula, have you tried formatting the cell to General?

Ak
 
Upvote 0

Forum statistics

Threads
1,215,036
Messages
6,122,796
Members
449,095
Latest member
m_smith_solihull

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top