Invoice Total calculation

Sirpeterjones

New Member
Joined
Mar 30, 2011
Messages
19
Office Version
  1. 365
Platform
  1. Windows
Hi Team, does someone know the right formula to calculate the invoice total where the pricing is a little complex.

1737526866617.png


I want to be able to enter the number of containers in the first 2 columns of the green section, then the total invoice amount will automatically calculate.

Where Unit price is per container - The first container is a higher rate, then every subsequent container is a lower rate
Where unit price is per 5 containers - we sell in batches of 5, so single price is per 5 units, $27.50 is for 5 containers, regardless if they use 1 or 5 we only charge $27.50, if they use 6-10 then it's another $27.50
Where unit price is per 10 x 20' - similar to per 5 containers, but each 40' counts as 2 x 20'
Where unit price is per 2 x 20' - similar to above, we price once per 2 x 20' and 1 x 40' = 2 x 20'
Certificate fee is only charged once regardless of the number of containers
Amendment fee is 25% of the total calculated invoice plus $30 of in the case of Cameroon it's a flat $63

Appreciate any help I can get to put this calculation together
Thank you
 

Excel Facts

Formula for Yesterday
Name Manager, New Name. Yesterday =TODAY()-1. OK. Then, use =YESTERDAY in any cell. Tomorrow could be =TODAY()+1.
A bit of a guess (it would help if you showed your required results) ...
Where unit price is per 10 x 20' - similar to per 5 containers, but each 40' counts as 2 x 20'
Where unit price is per 2 x 20' - similar to above, we price once per 2 x 20' and 1 x 40' = 2 x 20'

Can you please explain these two in more detail?

1. For Cameroon, does this mean each 20' is $61, and each 40' is $122?
2. For Congo, does this mean $110 for the first 20'/ first 2 x 20' / first 40'? And $86 for each subsequent 40' unit (or part thereof). So that, for example, 3 x 20' or 4 x 20' would both cost $196?

ABCDEFGHIJKLM
1CertAmendmentAmendmentContainerTotal
2First 20First 40Extra 20Extra 40UnitFeeFee 1Fee 2No 20No 40FeeInvoiceAmendment
3$120.00$175.00$75.00$130.001$95.00$30.0025%34$835.00$1,280.00$350.00
4$27.50$27.505$95.00$30.0025%63$82.50$276.67$99.17
5$61.00$61.001$95.00$63.0024$366.00$524.00$63.00
Sheet1
Cell Formulas
RangeFormula
K3:K5K3=IF(E3=1,I3*A3-(C3>0)*(I3-1)*(A3-C3)+J3*B3-(D3>0)*(J3-1)*(B3-D3),CEILING(I3,E3)/E3*A3+CEILING(J3,E3)/E3*B3)
L3:L5L3=(K3+SUM(F3:G3))/(1-H3)
M3:M5M3=H3*L3+G3
 
Last edited:
Upvote 0
Hi Stephen,
You have pretty much nailed it - it's just for row 4 the container fee should be $55 since there are a total of 9 containers, so 2 x multiples of 5.

1737606143740.png


Here are the desired results
For the last one - the first 2 x 20' equivalent units is $110, each multiple of 2 thereafter is $86

I have added the yellow columns to try show the combination total of 20' and 40'

I tried to play with your formula, but I couldn't get it to work.
 
Upvote 0
Ok thanks, here's my latest take ....

ABCDEFGHIJKLMN
1First 20Extra 20CertAmendmentAmendmentContainerTotal
2or first unitFirst 40or extra unitExtra 40UnitFeeFee 1Fee 2No 20No 40No UnitsFeeInvoiceAmendment
3$120.00$175.00$75.00$130.001$95.00$30.0025%347$835.00$1,280.00$350.00
4$27.505$95.00$30.0025%632$55.00$240.00$90.00
5$27.50$25.005$95.00$30.0025%632$52.50$236.67$89.17
6$61.0010x20$95.00$63.0022246$2,806.00$2,964.00$63.00
7$61.00$51.0010x20$95.00$63.0022246$2,356.00$2,514.00$63.00
8$110.002x20$95.00$30.0025%3810$1,100.00$1,633.33$438.33
9$110.00$86.002x20$95.00$30.0025%289$798.00$1,230.67$337.67
Sheet1
Cell Formulas
RangeFormula
K3:K5K3=IF(E3="10x20",I3+2*J3,IF(E3="2x20",ROUNDUP(I3/2+J3,0),ROUNDUP(SUM(I3:J3)/E3,0)))
L3:L9L3=IF(E3=1,I3*A3-(C3>0)*(I3-1)*(A3-C3)+J3*B3-(D3>0)*(J3-1)*(B3-D3),K3*A3-(C3>0)*(K3-1)*(A3-C3))
M3:M9M3=(L3+SUM(F3:G3))/(1-H3)
N3:N9N3=H3*M3+G3
K6K6=IF(E6="10x20",I6+2*J6,IF(E6="2x20",ROUNDUP(I6/2+J6,0),SUM(I6:J6)/E6))
K7:K9K7=IF(E7="10x20",I7+2*J7,IF(E7="2x20",ROUNDUP(I7/2+J7,0),""))

I'm grossing up the invoice differently to you, on the assumption (perhaps incorrect) that, for the first line

Total Invoice = $1,280 = Container Fee ($835) plus Cert Fee ($95) plus Amendment ($30 +25% of Total Invoice = $350)

It would be really helpful if you updated your Account details so we know what version of Excel you're using? You haven't replied to similar queries in your other threads, so we still don't know whether an Excel 365 solution would work for you.
 
Upvote 0
Ok thanks, here's my latest take ....

ABCDEFGHIJKLMN
1First 20Extra 20CertAmendmentAmendmentContainerTotal
2or first unitFirst 40or extra unitExtra 40UnitFeeFee 1Fee 2No 20No 40No UnitsFeeInvoiceAmendment
3$120.00$175.00$75.00$130.001$95.00$30.0025%347$835.00$1,280.00$350.00
4$27.505$95.00$30.0025%632$55.00$240.00$90.00
5$27.50$25.005$95.00$30.0025%632$52.50$236.67$89.17
6$61.0010x20$95.00$63.0022246$2,806.00$2,964.00$63.00
7$61.00$51.0010x20$95.00$63.0022246$2,356.00$2,514.00$63.00
8$110.002x20$95.00$30.0025%3810$1,100.00$1,633.33$438.33
9$110.00$86.002x20$95.00$30.0025%289$798.00$1,230.67$337.67
Sheet1
Cell Formulas
RangeFormula
K3:K5K3=IF(E3="10x20",I3+2*J3,IF(E3="2x20",ROUNDUP(I3/2+J3,0),ROUNDUP(SUM(I3:J3)/E3,0)))
L3:L9L3=IF(E3=1,I3*A3-(C3>0)*(I3-1)*(A3-C3)+J3*B3-(D3>0)*(J3-1)*(B3-D3),K3*A3-(C3>0)*(K3-1)*(A3-C3))
M3:M9M3=(L3+SUM(F3:G3))/(1-H3)
N3:N9N3=H3*M3+G3
K6K6=IF(E6="10x20",I6+2*J6,IF(E6="2x20",ROUNDUP(I6/2+J6,0),SUM(I6:J6)/E6))
K7:K9K7=IF(E7="10x20",I7+2*J7,IF(E7="2x20",ROUNDUP(I7/2+J7,0),""))

I'm grossing up the invoice differently to you, on the assumption (perhaps incorrect) that, for the first line

Total Invoice = $1,280 = Container Fee ($835) plus Cert Fee ($95) plus Amendment ($30 +25% of Total Invoice = $350)

It would be really helpful if you updated your Account details so we know what version of Excel you're using? You haven't replied to similar queries in your other threads, so we still don't know whether an Excel 365 solution would work for you.
Account details updated - I am using Office 365

Amendment fee does not apply to Total Invoice - this only applies if an Amendment is required and hence calculated separately

I have the calculations working properly now - Thank you!

Last question... How do I make Total Invoice and Amendment read as ZERO when there are no containers? See highlighted below in Yellow

1737623307024.png
 
Upvote 0
Great, I'm glad it's working for you, and thanks for clarifying the version, and the calculation.
Last question...
Like this perhaps:
FGHIJKLMN
1CertAmendmentAmendmentContainerTotal
2FeeFee 1Fee 2FeeInvoiceAmendment
3$95.00$30.0025%$835.00$930.00$262.50
4$95.00$30.0025%$90.00$185.00$76.25
5$95.00$30.0025%$55.00$150.00$67.50
6$95.00$30.0025%$52.50$147.50$66.88
7$95.00$63.00$2,806.00$2,901.00$63.00
8$95.00$63.00$0.00ZEROZERO
9$95.00$30.0025%$798.00$893.00$253.25
10$95.00$30.0025%$24.00$119.00$59.75
Sheet1
Cell Formulas
RangeFormula
M3:M10M3=IF(L3=0,"ZERO",L3+F3)
N3:N10N3=IF(L3=0,"ZERO",H3*M3+G3)
 
Upvote 0
Great, I'm glad it's working for you, and thanks for clarifying the version, and the calculation.

Like this perhaps:
FGHIJKLMN
1CertAmendmentAmendmentContainerTotal
2FeeFee 1Fee 2FeeInvoiceAmendment
3$95.00$30.0025%$835.00$930.00$262.50
4$95.00$30.0025%$90.00$185.00$76.25
5$95.00$30.0025%$55.00$150.00$67.50
6$95.00$30.0025%$52.50$147.50$66.88
7$95.00$63.00$2,806.00$2,901.00$63.00
8$95.00$63.00$0.00ZEROZERO
9$95.00$30.0025%$798.00$893.00$253.25
10$95.00$30.0025%$24.00$119.00$59.75
Sheet1
Cell Formulas
RangeFormula
M3:M10M3=IF(L3=0,"ZERO",L3+F3)
N3:N10N3=IF(L3=0,"ZERO",H3*M3+G3)

The issue I have is that L3 does not equal ZERO, using the formula provided, see row 4 below highlighted in yellow - despite "Number of 20'" and "Number of 40'" being 0 - it's showing $90, I don't know where this $90 is coming from?

1737646953365.png
 
Upvote 0
Sorry, my mistake - didn't check exhaustively. If there are zero containers, and a non-zero "extra" price, my formula was taking 1 x First price + (-1) x Extra Price.

Try:

ABCDEFGHIJKLMN
1First 20Extra 20CertAmendmentAmendmentContainerTotal
2or first unitFirst 40or extra unitExtra 40UnitFeeFee 1Fee 2No 20No 40No UnitsFeeInvoiceAmendment
3$120.00$175.00$75.00$130.001$95.00$30.0025%347$835.00$930.00$262.50
4$120.00$175.00$75.00$130.001$95.00$30.0025%0$0.00ZEROZERO
5$27.505$95.00$30.0025%632$55.00$150.00$67.50
6$27.50$25.005$95.00$30.0025%632$52.50$147.50$66.88
7$61.0010x20$95.00$63.0022246$2,806.00$2,901.00$63.00
8$61.00$51.0010x20$95.00$63.000$0.00ZEROZERO
9$110.00$86.002x20$95.00$30.0025%289$798.00$893.00$253.25
10$110.00$86.002x20$95.00$30.0025%0$0.00ZEROZERO
Sheet1
Cell Formulas
RangeFormula
K3:K6K3=IF(E3="10x20",I3+2*J3,IF(E3="2x20",ROUNDUP(I3/2+J3,0),ROUNDUP(SUM(I3:J3)/E3,0)))
L3:L10L3=IF(K3<1,0,IF(E3=1,I3*A3-(C3>0)*(I3-1)*(A3-C3)+J3*B3-(D3>0)*(J3-1)*(B3-D3),K3*A3-(C3>0)*(K3-1)*(A3-C3)))
M3:M10M3=IF(L3=0,"ZERO",L3+F3)
N3:N10N3=IF(L3=0,"ZERO",H3*M3+G3)
K7K7=IF(E7="10x20",I7+2*J7,IF(E7="2x20",ROUNDUP(I7/2+J7,0),SUM(I7:J7)/E7))
K8:K10K8=IF(E8="10x20",I8+2*J8,IF(E8="2x20",ROUNDUP(I8/2+J8,0),""))

I don't know if it's an option for you, but I'd be tempted to use a VBA function when calculations reach around this level of complexity - especially if there's potential for other fee arrangements to be added. I find it easier to debug, amend and add new cases in something that looks like this:

VBA Code:
Function ContainerFee(Units As String, ... etc ) As Double
    
    Select Case Units
    
    Case "Per container"
        ContainerFee = IIf(No20 > 0, First20 + (No20 - 1) * Extra20, 0) + IIf(No40 > 0, First40 + (No40 - 1) * Extra40, 0)
    
    'Case ....
    
    
    'Case ....
    
    
    End Select

End Function
 
Upvote 0
Sorry, my mistake - didn't check exhaustively. If there are zero containers, and a non-zero "extra" price, my formula was taking 1 x First price + (-1) x Extra Price.

Try:

ABCDEFGHIJKLMN
1First 20Extra 20CertAmendmentAmendmentContainerTotal
2or first unitFirst 40or extra unitExtra 40UnitFeeFee 1Fee 2No 20No 40No UnitsFeeInvoiceAmendment
3$120.00$175.00$75.00$130.001$95.00$30.0025%347$835.00$930.00$262.50
4$120.00$175.00$75.00$130.001$95.00$30.0025%0$0.00ZEROZERO
5$27.505$95.00$30.0025%632$55.00$150.00$67.50
6$27.50$25.005$95.00$30.0025%632$52.50$147.50$66.88
7$61.0010x20$95.00$63.0022246$2,806.00$2,901.00$63.00
8$61.00$51.0010x20$95.00$63.000$0.00ZEROZERO
9$110.00$86.002x20$95.00$30.0025%289$798.00$893.00$253.25
10$110.00$86.002x20$95.00$30.0025%0$0.00ZEROZERO
Sheet1
Cell Formulas
RangeFormula
K3:K6K3=IF(E3="10x20",I3+2*J3,IF(E3="2x20",ROUNDUP(I3/2+J3,0),ROUNDUP(SUM(I3:J3)/E3,0)))
L3:L10L3=IF(K3<1,0,IF(E3=1,I3*A3-(C3>0)*(I3-1)*(A3-C3)+J3*B3-(D3>0)*(J3-1)*(B3-D3),K3*A3-(C3>0)*(K3-1)*(A3-C3)))
M3:M10M3=IF(L3=0,"ZERO",L3+F3)
N3:N10N3=IF(L3=0,"ZERO",H3*M3+G3)
K7K7=IF(E7="10x20",I7+2*J7,IF(E7="2x20",ROUNDUP(I7/2+J7,0),SUM(I7:J7)/E7))
K8:K10K8=IF(E8="10x20",I8+2*J8,IF(E8="2x20",ROUNDUP(I8/2+J8,0),""))

I don't know if it's an option for you, but I'd be tempted to use a VBA function when calculations reach around this level of complexity - especially if there's potential for other fee arrangements to be added. I find it easier to debug, amend and add new cases in something that looks like this:

VBA Code:
Function ContainerFee(Units As String, ... etc ) As Double
   
    Select Case Units
   
    Case "Per container"
        ContainerFee = IIf(No20 > 0, First20 + (No20 - 1) * Extra20, 0) + IIf(No40 > 0, First40 + (No40 - 1) * Extra40, 0)
   
    'Case ....
   
   
    'Case ....
   
   
    End Select

End Function
You are such a legend!! Thank you for all your help and your patience in helping me out! It is very much appreciated.

The VBA looks impressive, but outside of my skillset unfortunately - thank you anyway!
 
Upvote 0
Ok thanks, here's my latest take ....

ABCDEFGHIJKLMN
1First 20Extra 20CertAmendmentAmendmentContainerTotal
2or first unitFirst 40or extra unitExtra 40UnitFeeFee 1Fee 2No 20No 40No UnitsFeeInvoiceAmendment
3$120.00$175.00$75.00$130.001$95.00$30.0025%347$835.00$1,280.00$350.00
4$27.505$95.00$30.0025%632$55.00$240.00$90.00
5$27.50$25.005$95.00$30.0025%632$52.50$236.67$89.17
6$61.0010x20$95.00$63.0022246$2,806.00$2,964.00$63.00
7$61.00$51.0010x20$95.00$63.0022246$2,356.00$2,514.00$63.00
8$110.002x20$95.00$30.0025%3810$1,100.00$1,633.33$438.33
9$110.00$86.002x20$95.00$30.0025%289$798.00$1,230.67$337.67
Sheet1
Cell Formulas
RangeFormula
K3:K5K3=IF(E3="10x20",I3+2*J3,IF(E3="2x20",ROUNDUP(I3/2+J3,0),ROUNDUP(SUM(I3:J3)/E3,0)))
L3:L9L3=IF(E3=1,I3*A3-(C3>0)*(I3-1)*(A3-C3)+J3*B3-(D3>0)*(J3-1)*(B3-D3),K3*A3-(C3>0)*(K3-1)*(A3-C3))
M3:M9M3=(L3+SUM(F3:G3))/(1-H3)
N3:N9N3=H3*M3+G3
K6K6=IF(E6="10x20",I6+2*J6,IF(E6="2x20",ROUNDUP(I6/2+J6,0),SUM(I6:J6)/E6))
K7:K9K7=IF(E7="10x20",I7+2*J7,IF(E7="2x20",ROUNDUP(I7/2+J7,0),""))

I'm grossing up the invoice differently to you, on the assumption (perhaps incorrect) that, for the first line

Total Invoice = $1,280 = Container Fee ($835) plus Cert Fee ($95) plus Amendment ($30 +25% of Total Invoice = $350)

It would be really helpful if you updated your Account details so we know what version of Excel you're using? You haven't replied to similar queries in your other threads, so we still don't know whether an Excel 365 solution would work for you.
I found an error in the number of units for 10x20

Where Unit = "10x20" - 2 x 20' and 22 x 40' - total units should be 5 since there are 46 x 20' equivalent units, which = 5 x multiples of 10

Where Unit = "2x20'" the calculation is working

I have tried to work with the formula but I can't make it work :(

This should be my last question... sorry!
 
Upvote 0

Forum statistics

Threads
1,226,017
Messages
6,188,441
Members
453,474
Latest member
th9r

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