+ Reply to Thread
Results 1 to 10 of 10

Calculate cost of gas usage with different rates

  1. #1
    Registered User
    Join Date
    09-09-2010
    Location
    Australia
    MS-Off Ver
    Excel 2013
    Posts
    13

    Calculate cost of gas usage with different rates

    Hi, I am trying to calculate the cost of gas depending on usage. There are 4 different rates for each band. The more you use the cheaper it gets per Mega Joule. The rate are as follows.

    First 4000 MJ = 0.023 cent / MJ
    Next 5000 MJ = 0.018 cent / MJ
    Next 10000 MJ = 0.012 cent / MJ
    balance = 0.009 cent / MJ

    Now lets say the user has consumed 22000 MJ in the month, how can I calculate this? I can calculate if there are two bands by using IF function but I am having difficulty with four different rates.

    Thanks in advance
    Last edited by kryptic; 12-03-2011 at 11:37 AM.

  2. #2
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    2016
    Posts
    14,675

    Re: Calculate cost of gas usage with different rates

    Try using the methods suggested here
    Audere est facere

  3. #3
    Forum Contributor
    Join Date
    11-26-2011
    Location
    India
    MS-Off Ver
    Excel 2007
    Posts
    159

    Re: Calculate cost of gas usage with different rates

    Quote Originally Posted by kryptic View Post
    Hi, I am trying to calculate the cost of gas depending on usage. There are 4 different rates for each band. The more you use the cheaper it gets per Mega Joule. The rate are as follows.

    First 4000 MJ = 0.023 cent / MJ
    Next 5000 MJ = 0.018 cent / MJ
    Next 10000 MJ = 0.012 cent / MJ
    balance = 0.009 cent / MJ

    Now lets say the user has consumed 22000 MJ in the month, how can I calculate this? I can calculate if there are two bands by using IF function but I am having difficulty with four different rates.

    Thanks in advance
    As per my understanding about your query

    my formula as follows
    let data is in A1, then copy this formula in B1
    =IF(A1<5000,A1*0.023,IF(AND(A1>=5000,A1<=9999),A1*0.018,IF(A1>=10000,A1*0.012,"")))

    And I didnt get last one balance = 0.009 cent/MJ so I didnt include it... can more explain more clearly so that you can get better solution from other experts

  4. #4
    Registered User
    Join Date
    11-24-2011
    Location
    Chattanooga, TN
    MS-Off Ver
    Microsoft 365 MSO (Version 2303 Build 16.0.16227.20202) 64-bit
    Posts
    11

    Re: Calculate cost of gas usage with different rates

    If your set up was:
    B2 is input
    B5 4000
    B6 5000
    B7 10,000
    B8 >10000

    Column C on the same row would be the $.


    =IF(B2<B5,B2*C5,IF(AND(B2<B6,B2>B5),C6*B2,IF(AND(B2<B7,B2>B6),C7*B2,IF(B2>B8,C8*B2))))

    In other words, in your IF statement, you have condition, value if true, value if false. To use multiple IF statements, at the you put Condition, Value if True, Next If statement Condition, Value if True, continue until the last statement and then ,value if false.

    Also, I am very amateur at Excel. I am sure there are other, better ways of doing this, but maybe it will help.
    Last edited by the tax man; 11-27-2011 at 11:13 AM. Reason: I forgot to add something

  5. #5
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    2016
    Posts
    14,675

    Re: Calculate cost of gas usage with different rates

    I'm assuming that kryptic wants to apply different rates to different parts of the 22,000 total units. The link I posted shows a method to do that, the other suggestions here will apply the same rate to all 22,000....

  6. #6
    Registered User
    Join Date
    11-24-2011
    Location
    Chattanooga, TN
    MS-Off Ver
    Microsoft 365 MSO (Version 2303 Build 16.0.16227.20202) 64-bit
    Posts
    11

    Re: Calculate cost of gas usage with different rates

    True . . . I didn't think of that.

  7. #7
    Registered User
    Join Date
    09-09-2010
    Location
    Australia
    MS-Off Ver
    Excel 2013
    Posts
    13

    Re: Calculate cost of gas usage with different rates

    Quote Originally Posted by daddylonglegs View Post
    I'm assuming that kryptic wants to apply different rates to different parts of the 22,000 total units. The link I posted shows a method to do that, the other suggestions here will apply the same rate to all 22,000....
    Yeah different rates to different parts of the 22000 units. The total amount should be $327.

    4000 * 0.023 = $92
    5000 * 0.018 = $90
    10000 * 0.012 = $120
    3000 * 0.009 = $27
    -------------------------------
    22000 = $327

    Unfortunately I can't do SUMPRODUCT as its too hard to understand it. I have read through but still can't figure out.

    This is what I am using but I get $1142 for 22000 units. I have 22000 in Cell C3. I have 0, 4000, 5000, 10000 in Cell C6:C9 respectively then I have the rates in Cell C19:C22.

    =SUMPRODUCT(--(C3>C6:C9), (C3-C6:C9), (C19:C22))

    SUMPRODUCT seems for advanced user. What am I doing wrong? Can someone just post the formula please?

    Thanks
    Last edited by kryptic; 11-28-2011 at 04:46 AM. Reason: changed 20000 to 22000

  8. #8
    Registered User
    Join Date
    09-09-2010
    Location
    Australia
    MS-Off Ver
    Excel 2013
    Posts
    13

    Re: Calculate cost of gas usage with different rates

    Seems no one have come up to the solution for this. Anyone?

  9. #9
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    2016
    Posts
    14,675

    Re: Calculate cost of gas usage with different rates

    Sorry, I didn't see your previous reply....

    You are almost there. The amounts in C6:C9 should be the cumulative amounts so C6 should be 0 and C7 4000 but then C8 should be 9000 and C9 19000.

    Formula can be

    =SUMPRODUCT(--(C3>C6:C9), C3-C6:C9,C19:C22-C18:C21)

    C18 cell should be blank or zero. For 22000 in C3 that will give the correct result of 329 (not 327).

    An alternative formula to give the same result without SUMPRODUCT (but no better)

    =IF(C3="","",C3*C22-MIN(C3,C9)*(C22-C21)-MIN(C3,C8)*(C21-C20)-MIN(C3,C7)*(C20-C19))

    see attached
    Attached Files Attached Files

  10. #10
    Registered User
    Join Date
    09-09-2010
    Location
    Australia
    MS-Off Ver
    Excel 2013
    Posts
    13

    Re: Calculate cost of gas usage with different rates

    Thank you very much daddylonglegs. You have made my day. Both formula works great. I was stuck at how to deduct in the last part of sumproduct formula.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1