Complex IF statement to work out optimatl billing model

eddowding

New Member
Joined
May 20, 2011
Messages
3
Here's fun! :)

I'm helping a friend who is trying to work out how much to charge for house calls. He has lots of data. The average house call lasts about 15 minutes, but some as low a 5 mins, some as high as two hours.

We're trying to work out if he should have a minimum billiing period, and how to charge the minutes after that.

We've got these variables:
Code:
Min billing period (m)	20
Billing chunks (m)      15
Positive Leeway	        30%
Price per min before 	1
Price per min after	1.5

The "positive leeway" is in there because if a house call takes eg 38 minutes, there's the minimum biling period of 20 mins, then another chunk of 15 mins, and then another 3 minutes unbilled. It seems unfair to charge another 15 minutes for a 3 minute block, so we've added leeway in there to say if it's less than 30% in to another chunk, don't bill it.

(An obvious answer to this would be to bill in 5 minute increments, which we might do, too; we're just testing the scenarios)

So in words, it works out like this:

IF DURATION < MIN BILL PERIOD THEN PRICE = MIN BILL * PER MIN BEFORE
ELSE IF DUR > MIN BILL PERIOD THEN PRICE = ((how many billing chunks more than the min.billing.price, rounded DOWN if less than LEEWAY over, else rounded up) * price per min after)

Eg if duration = 8, then 8 is less than 20, so price = 20 * 1 = 20
Eg if duration = 38, then price is the (MINBILLPERIOD * price before) + (one BillingChunk * price after), since the second billing chunk is less than 30% over

I got as far as creating an If statement for the minimum billing but then realised I was going to have to ask a pro!

Can anyone give me some pointers?

Thank you!
 

Excel Facts

What is =ROMAN(40) in Excel?
The Roman numeral for 40 is XL. Bill "MrExcel" Jelen's 40th book was called MrExcel XL.
Very interesting problem.

Here's my attempt:
Sheet 1

<TABLE style="PADDING-RIGHT: 2pt; PADDING-LEFT: 2pt; FONT-SIZE: 11pt; FONT-FAMILY: Calibri,Arial; BACKGROUND-COLOR: #ffffff" cellSpacing=0 cellPadding=0 border=1><COLGROUP><COL style="FONT-WEIGHT: bold; WIDTH: 30px"><COL style="WIDTH: 152px"><COL style="WIDTH: 64px"><COL style="WIDTH: 64px"><COL style="WIDTH: 64px"><COL style="WIDTH: 64px"></COLGROUP><TBODY><TR style="FONT-WEIGHT: bold; FONT-SIZE: 8pt; BACKGROUND-COLOR: #cacaca; TEXT-ALIGN: center"><TD></TD><TD>A</TD><TD>B</TD><TD>C</TD><TD>D</TD><TD>E</TD></TR><TR style="HEIGHT: 18px"><TD style="FONT-SIZE: 8pt; BACKGROUND-COLOR: #cacaca; TEXT-ALIGN: center">1</TD><TD>Min billing period (m)</TD><TD style="TEXT-ALIGN: right">20</TD><TD></TD><TD style="TEXT-ALIGN: right">39</TD><TD style="TEXT-ALIGN: right">42.5</TD></TR><TR style="HEIGHT: 18px"><TD style="FONT-SIZE: 8pt; BACKGROUND-COLOR: #cacaca; TEXT-ALIGN: center">2</TD><TD>Billing chunks (m) </TD><TD style="TEXT-ALIGN: right">15</TD><TD></TD><TD></TD><TD></TD></TR><TR style="HEIGHT: 18px"><TD style="FONT-SIZE: 8pt; BACKGROUND-COLOR: #cacaca; TEXT-ALIGN: center">3</TD><TD>Positive Leeway</TD><TD style="TEXT-ALIGN: right">30%</TD><TD></TD><TD></TD><TD></TD></TR><TR style="HEIGHT: 18px"><TD style="FONT-SIZE: 8pt; BACKGROUND-COLOR: #cacaca; TEXT-ALIGN: center">4</TD><TD>Price per min before </TD><TD style="TEXT-ALIGN: right">1</TD><TD></TD><TD></TD><TD></TD></TR><TR style="HEIGHT: 18px"><TD style="FONT-SIZE: 8pt; BACKGROUND-COLOR: #cacaca; TEXT-ALIGN: center">5</TD><TD>Price per min after</TD><TD style="TEXT-ALIGN: right">1.5</TD><TD></TD><TD></TD><TD></TD></TR></TBODY></TABLE>


Formula in E1:
Code:
=IF(D1<=$B$1,D1*$B$4,IF(MOD((D1-$B$1),$B$2)>($B$3*$B$2),$B$1*$B$4+$B$5*(D1-$B$1),$B$1*$B$4+INT((D1-$B$1)/$B$2)*$B$2*$B$5))

I'm sure there's a more compact way of doing it.
 
Upvote 0
Sorry, I just realised that you want to charge in chunks and not minutes. This should do that:
Code:
=$B$1*$B$4+(INT((D1-$B$1)/$B$2)+(MOD((D1-$B$1),$B$2)>($B$3*$B$2)))*$B$2*$B$5
 
Last edited:
Upvote 0
Syntaxed - thank you! This sis great!

I've realised that OpenOffice doesn't support the same formulas as excel, though, which is a pity since it's what I'm using. I'll have a crack with google docs to see if that handles it.

What would you change to make it bill a minimum of the 20 minute period? I guess it's another IF, and then with the rest of that formula in an ELSE?
 
Upvote 0
=if(d1>=$b$1,if(mod((d1-$b$1),$b$2)<($b$2*$b$3),int((d1-$b$1)/15)*$b$2*$b$5+20,int((d1-$b$1)/$b$2)*$b$2*$b$5+(mod((d1-$b$1),$b$2)*$b$5)+$b$1),$b$1*$b$4)
 
Upvote 0
eddowding: Glad it works. Sorry for all the alterations. To incorporate the minimum billing period amount, you could use a Max as follows:

Sheet 1

<TABLE style="PADDING-RIGHT: 2pt; PADDING-LEFT: 2pt; FONT-SIZE: 11pt; FONT-FAMILY: Calibri,Arial; BACKGROUND-COLOR: #ffffff" cellSpacing=0 cellPadding=0 border=1><COLGROUP><COL style="FONT-WEIGHT: bold; WIDTH: 30px"><COL style="WIDTH: 152px"><COL style="WIDTH: 64px"><COL style="WIDTH: 64px"><COL style="WIDTH: 64px"><COL style="WIDTH: 64px"></COLGROUP><TBODY><TR style="FONT-WEIGHT: bold; FONT-SIZE: 8pt; BACKGROUND-COLOR: #cacaca; TEXT-ALIGN: center"><TD></TD><TD>A</TD><TD>B</TD><TD>C</TD><TD>D</TD><TD>E</TD></TR><TR style="HEIGHT: 18px"><TD style="FONT-SIZE: 8pt; BACKGROUND-COLOR: #cacaca; TEXT-ALIGN: center">1</TD><TD>Min billing period (m)</TD><TD style="TEXT-ALIGN: right">20</TD><TD></TD><TD style="TEXT-ALIGN: right">20</TD><TD style="TEXT-ALIGN: right">20</TD></TR><TR style="HEIGHT: 18px"><TD style="FONT-SIZE: 8pt; BACKGROUND-COLOR: #cacaca; TEXT-ALIGN: center">2</TD><TD>Billing chunks (m) </TD><TD style="TEXT-ALIGN: right">15</TD><TD></TD><TD></TD><TD></TD></TR><TR style="HEIGHT: 18px"><TD style="FONT-SIZE: 8pt; BACKGROUND-COLOR: #cacaca; TEXT-ALIGN: center">3</TD><TD>Positive Leeway</TD><TD style="TEXT-ALIGN: right">30%</TD><TD></TD><TD></TD><TD></TD></TR><TR style="HEIGHT: 18px"><TD style="FONT-SIZE: 8pt; BACKGROUND-COLOR: #cacaca; TEXT-ALIGN: center">4</TD><TD>Price per min before </TD><TD style="TEXT-ALIGN: right">1</TD><TD></TD><TD></TD><TD></TD></TR><TR style="HEIGHT: 18px"><TD style="FONT-SIZE: 8pt; BACKGROUND-COLOR: #cacaca; TEXT-ALIGN: center">5</TD><TD>Price per min after</TD><TD style="TEXT-ALIGN: right">1.5</TD><TD></TD><TD></TD><TD></TD></TR></TBODY></TABLE>
<TABLE style="FONT-SIZE: 10pt; BORDER-LEFT-COLOR: #00ff00; BORDER-BOTTOM-COLOR: #00ff00; COLOR: #000000; BORDER-TOP-STYLE: groove; BORDER-TOP-COLOR: #00ff00; FONT-FAMILY: Arial; BORDER-RIGHT-STYLE: groove; BORDER-LEFT-STYLE: groove; BACKGROUND-COLOR: #fffcf9; BORDER-RIGHT-COLOR: #00ff00; BORDER-BOTTOM-STYLE: groove"><TBODY><TR><TD>Spreadsheet Formulas</TD></TR><TR><TD><TABLE style="FONT-SIZE: 9pt; FONT-FAMILY: Arial" cellSpacing=0 cellPadding=2 border=1><TBODY><TR style="FONT-SIZE: 10pt; BACKGROUND-COLOR: #cacaca"><TD>Cell</TD><TD>Formula</TD></TR><TR><TD>E1</TD><TD>=MAX($B$1*$B$4+(INT((D1-$B$1)/$B$2)+(MOD((D1-$B$1),$B$2)>($B$3*$B$2)))*$B$2*$B$5,$B$1*$B$4)</TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE>

Excel tables to the web >> http://www.excel-jeanie-html.de/index.php?f=1" target="_blank"> Excel Jeanie HTML 4
 
Upvote 0
Code:
=IF(D1>=$B$1,IF(MOD((D1-$B$1),$B$2)<($B$2*$B$3),INT((D1-$B$1)/15)*$B$2*$B$5+20,(INT((D1-$B$1)/$B$2)+1)*$B$2*$B$5+$B$1),$B$1*$B$4)

bah.. im slow lol
 
Upvote 0
This is amazing - thank you!! Exactly what I was after. And i can confirm it works in Google Docs :)

Not to plug some numbers in there and do some goal seeking!

Thank you, thank you! May your weekends be great!
 
Upvote 0

Forum statistics

Threads
1,215,128
Messages
6,123,204
Members
449,090
Latest member
bes000

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