Fixed minimum rate for prorating calculation

Lil Stinker

Board Regular
Joined
Feb 16, 2022
Messages
151
Office Version
  1. 2019
Platform
  1. Windows
Hello-
I'm looking for a way to fix in a minimum rate when calculating for monthly or weekly rental terms. In the samples below, I have the same table indicating the result for a monthly rental and a weekly rental based on a drop down in column E. The idea is the user will select Months or Weeks based on the term they are choosing for the rental when placing an order. Each term however, has a minimum rental rate regardless of which is chosen. Weekly rentals have a minimum 7-day rental while Monthly has a minimum one month rental. If a weekly rental is selected but the duration is less than 7 days, it should still total whatever weekly rate is listed in the Unit Rate column rather than breaking it down by the day as it currently does. Same for when a monthly rental is selected on the form, if the duration is less than a month, it should still total the monthly rate listed in column D. It is only after the minimum is met, does the rental start to prorate.

The two tables I have off to the right are there for calculating the proration for either rental term. I have it set up this way because this seems to produce the most accurate proration of rental rates for our needs. The problem is, it does not factor in a minimum rental period. So, I don't know if a more detailed IF statement in the Item Subtotal column is the way to go or if different formulas are needed in each of the calculation tables to factor in the minimum rental rate but I do know that I'm not smart enough to figure it out.

Any help would be greatly appreciated.

(By the way, this is meant to be used for drafting quotes to our clients. The start and end dates, equipment and rental rates are not fixed and will vary per quote).

ORDER FORM -formula tests- 2022.xlsx
ABCDEFGHIJKLMNOPQRS
17DescriptionQTYUnit RateMonthsItem Subtotal[ Term ]MonthsWeeksDaysWeekly RateDaily RateSubtotalWeeksDaysDaily RateSubtotal
18Computer Monitor1200.003w,6d$192.84Months0.003.006.0050.007.14192.843.006.0028.57771.42
19Speaker Set250.003w,6d$96.48Weeks0.003.006.0012.501.7996.483.006.007.14385.68
20Start DateKeyboard & Mouse Set120.003w,6d$19.260.003.006.005.000.7119.263.006.002.8677.16
2103/01/22Computer Tower1500.003w,6d$482.160.003.006.00125.0017.86482.163.006.0071.431928.58
22End Date            
2303/28/22            
24            
25            
26            
27Subtotal$790.74  
28Discount$0.00  
29Net Amount$790.74  
30TOTAL AMOUNT$790.74  
31
32DescriptionQTYUnit RateWeeksItem Subtotal[ Term ]MonthsWeeksDaysWeekly RateDaily RateSubtotalWeeksDaysDaily RateSubtotal
33Computer Monitor1200.006d$171.42Months0.000.006.0050.007.1442.840.006.0028.57171.42
34Speaker Set250.006d$85.68Weeks0.000.006.0012.501.7921.480.006.007.1485.68
35Start DateKeyboard & Mouse Set120.006d$17.160.000.006.005.000.714.260.006.002.8617.16
3604/01/22Computer Tower1500.006d$428.580.000.006.00125.0017.86107.160.006.0071.43428.58
37End Date            
3804/07/22            
39            
40            
41            
42Subtotal$702.84  
43Discount$0.00  
44Net Amount$702.84  
45TOTAL AMOUNT$702.84  
Sheet 2
Cell Formulas
RangeFormula
I18:I26I18=IF(ISBLANK(C18),"",DATEDIF($A$21,$A$23,"M"))
J18:J26J18=IF(ISBLANK(C18),"",INT(($A$23-EDATE($A$21,DATEDIF($A$21,$A$23,"m")))/7))
K18:K26K18=IF(ISBLANK(C18),"",MOD($A$23-EDATE($A$21,DATEDIF($A$21,$A$23,"m")),7))
L33:L41,L18:L26L18=IF(ISBLANK(C18),"",(ROUND(D18/4,2)))
M33:M41,M18:M26M18=IF(ISBLANK(C18),"",(ROUND(L18/7,2)))
N33:N41,N18:N26N18=IF(ISBLANK(C18),"",(D18*I18+L18*J18+M18*K18)*C18)
P18:P26P18=IF(ISBLANK(C18),"",INT((DATEDIF($A$21,$A$23,"d")/7)))
Q18:Q26Q18=IF(ISBLANK(C18),"",MOD($A$23-EDATE($A$21,DATEDIF($A$21,$A$23,"m")),7))
R33:R41,R18:R26R18=IF(ISBLANK(C18),"",(ROUND(D18/7,2)))
S33:S41,S18:S26S18=IF(ISBLANK(C18),"",(D18*P18+R18*Q18)*C18)
E18:E26E18=IF(OR($B18="",AND(E$17<>"Months",E$17<>"Weeks")),"", SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(IF(E$17="Months",DATEDIF($A$21,$A$23,"m")&"m,"&INT(($A$23-EDATE($A$21,DATEDIF($A$21,$A$23,"m")))/7)&"w,"&MOD($A$23-EDATE($A$21,DATEDIF($A$21,$A$23,"m")),7)&"d", INT(($A$23-$A$21)/7)&"w,"&MOD($A$23-$A$21,7)&"d"),"0m,",""),"0w,",""),",0d",""))
F18:F26F18=IF(ISBLANK(C18),"",IF(E$17="Months",(D18*I18+L18*J18+M18*K18)*C18,IF(E$17="Weeks",((D18*P18+R18*Q18)*C18))))
F27F27=SUBTOTAL(109,Table2261013[Item Subtotal])
L42:L45,L27:L30L27=IF(ISBLANK(C22),"",(ROUND(K27/7,2)))
M42:M45,M27:M30M27=IF(ISBLANK(C22),"",(D22*H27+K27*I27+L27*J27)*C22)
F29,F44F29=(F27-(F27*F28))
F30,F45F30=F29
I33:I41I33=IF(ISBLANK(C33),"",DATEDIF($A$36,$A$38,"M"))
J33:J41J33=IF(ISBLANK(C33),"",INT(($A$38-EDATE($A$36,DATEDIF($A$36,$A$38,"m")))/7))
K33:K41K33=IF(ISBLANK(C33),"",MOD($A$38-EDATE($A$36,DATEDIF($A$36,$A$38,"m")),7))
P33:P41P33=IF(ISBLANK(C33),"",INT((DATEDIF($A$36,$A$38,"d")/7)))
Q33:Q41Q33=IF(ISBLANK(C33),"",MOD($A$38-EDATE($A$36,DATEDIF($A$36,$A$38,"m")),7))
E33:E41E33=IF(OR($B33="",AND(E$32<>"Months",E$32<>"Weeks")),"", SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(IF(E$32="Months",DATEDIF($A$36,$A$38,"m")&"m,"&INT(($A$38-EDATE($A$36,DATEDIF($A$36,$A$38,"m")))/7)&"w,"&MOD($A$38-EDATE($A$36,DATEDIF($A$36,$A$38,"m")),7)&"d", INT(($A$38-$A$36)/7)&"w,"&MOD($A$38-$A$36,7)&"d"),"0m,",""),"0w,",""),",0d",""))
F33:F41F33=IF(ISBLANK(C33),"",IF(E$32="Months",(D33*I33+L33*J33+M33*K33)*C33,IF(E$32="Weeks",((D33*P33+R33*Q33)*C33))))
F42F42=SUBTOTAL(109,Table226101316[Item Subtotal])
Cells with Data Validation
CellAllowCriteria
E17List=$H$1:$H$3
E32List=$H$1:$H$3
 

Excel Facts

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)
The issue with basing everything off of a monthly rate even when it is a weekly rental is the daily rate would end up being too low because it would calculate at 1/28th of the month rather than 1/7th of the week—if I’m understanding you correctly. Rather than having a $100 weekly rate equal $14.29 a day once it went over a week, the daily rate would be $3.57.
Yes...that was my point. Inputted "Monthly" rates essentially lead to weekly and daily rates that define a month as 4 weeks or 28 days, whereas inputted "Weekly" rates do not define a month this way (in fact, there is no month definition in this case, only weeks and days). So if inputted "Weekly" rates were determined in your lookup tables as "Monthly" rate/4 (they probably are not), there would never be any instance where a Weekly rate would be preferred over the Monthly rate. At best the two would be equivalent, and in many cases, the Monthly rate would be preferred. But after reading your response, I don't think this is an issue, as you've clarified that you have both Weekly rates and Monthly rates (and Weekly is probably somewhat greater than Monthly/4) and Monthly rates must apply to rental durations >=1 month...so those clarifications put this issue to rest.

Give this version a try. You should be able to click on the clipboard icon in the upper left (at intersection of rows and columns headings) and then paste into into cell A18 on some worksheet where you have room to accommodate it. The formulas should come along with this operation. I'm not sure if you need the XL2BB add-in installed for this feature, but give it a try to see. This version addresses the rounding clarification and requires "Months" to be specified...and that fixes the other issue I noticed and mentioned (about rounding) a few posts back. Let me know if you encounter any unexpected issues or the "7d" issue you described.
mrexcel_20220406.xlsx
ABCDEFGHIJKLMNOPQRST
18OriginalConditional
19Date RangeDescriptionQTYUnit RateMonthsItem SubtotalTerms: MonthsNum MonthsNum WeeksNum DaysNum MonthsNum WeeksNum DaysMonthly RateWeekly RateDaily RateSubtotalRental Period
20Computer Monitor12001m200.00Months041100200.0050.007.14200.001m,0w,0d
21Speaker Set2501m100.00Months04110050.0012.501.79100.001m,0w,0d
22Start DateKeyboard & Mouse Set1201m20.00Months04110020.005.000.7120.001m,0w,0d
234/12/22Computer Tower15001m500.00Months041100500.00125.0017.86500.001m,0w,0d
24End Date              
255/10/22              
26              
27              
28              
29Subtotal820.00
30Discount10.0%
31Net Amount738.00
32TOTAL AMOUNT738.00
Lil Stinker
Cell Formulas
RangeFormula
I19I19="Terms: "&$E19
I20:I28I20=IF(ISBLANK(C20),"",SUBSTITUTE(I$19,"Terms: ",""))
J20:J28J20=IF(ISBLANK(C20),"",IF(I20="Months",DATEDIF($A$23,$A$25+1,"M"),0))
K20:K28K20=IF(ISBLANK(C20),"",QUOTIENT(DATEDIF(EDATE($A$23,J20),$A$25+1,"D"),7))
L20:L28L20=IF(ISBLANK(C20),"",DATEDIF(EDATE($A$23,J20),$A$25+1,"D")-7*K20)
M20:M28M20=IF(ISBLANK(C20),"",IF(AND(I20="Months",K20=4),J20+1,J20))
N20:N28N20=IF(ISBLANK(C20),"",IF(AND(I20="Months",K20=4),0,K20))
O20:O28O20=IF(ISBLANK(C20),"",IF(AND(I20="Months",K20=4),0,L20))
P20:P28P20=IF(ISBLANK(C20),"",IF(I20="Months",D20,""))
Q20:Q28Q20=IF(ISBLANK(C20),"",IF(I20="Months",ROUND(D20/4,2),D20))
R20:R28R20=IF(ISBLANK(C20),"",(ROUND(Q20/7,2)))
S20:S28S20=IF(ISBLANK(C20),"",C20*SUMPRODUCT(M20:O20,P20:R20))
T20:T28T20=IF(ISBLANK(C20),"",M20&"m,"&N20&"w,"&O20&"d")
E20:E28E20=IF($B20="","",SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(T20,"0m,",""),"0w,",""),",0d",""))
F20:F28F20=S20
F29F29=SUBTOTAL(109,F20:F28)
F31F31=F29*(1-F30)
F32F32=F31
Cells with Data Validation
CellAllowCriteria
E19ListMonths,Weeks
 
Upvote 0
I reviewed your comments in posts 8,12, and 15. I think the latest version may be what you want, but I am not sure about the rounding. In your posts, you suggest that when the user chooses "Months", then any time the rental duration computation produces a M/W/D result where W=4, the result should be automatically rounded to (M+1)/0/0. This rule is implemented such that a "Months" rental from 7/1/2022 to 7/28/20220 is initially determined to be 0m4w0d, and finally resolved to be 1m. Similarly...

7/1/2022-7/28/20220m4w0d1m
7/1/2022-7/29/20220m4w1d1m
7/1/2022-7/30/20220m4w2d1m
7/1/2022-7/31/20221m0w0d1m
7/1/2022-8/1/20221m0w1d1m,1d
So 4 weeks and a couple or fewer days (depending on the month) results in rounding the term up to a whole month, and the slightly better monthly rate gives a more favorable (for the customer) total compared to using the weekly/daily rates derived from the monthly rate. This rounding rule applies only to a user-specified "Months" input---a "Weeks" input gives different results, reported in terms of weeks and days with no rounding. I believe this is consistent with your description. This approach will not automatically change a "Weeks" rental into a "Months" rental because it has no way of knowing how to convert an input "Weeks" Unit Rate into a "Months" Unit Rate. The assumption is that the user-input Unit Rates apply only to the term selected in the column E heading---either "Weeks" or "Months". Please let me know if I've missed something or if you discover some unexpected/unwanted behavior.
 
Upvote 0
Regarding the 1w, 7d issue, you beat me to the punch. I was just about to post the original formulas from Post #6 when I saw you had posted this new form. Near as I can tell, the only difference between the two forms is there was "+1" missing from the Num Weeks column K formula in the original that led to the error. Once I added in +1 to that formula, the error I received displaying 1w, 7d corrected to 2w.

Personally, when it comes to duplicating the formulas in my workbook, I prefer to manually copy them as opposed to copy/paste because it helps me attempt to understand the formula and commit at least some of it to memory... even when I have no clear clue as to how it all works.

For all intents and purposes, this new form seems to work perfectly regarding weekly/monthly dates and rounding to whole months. However, now it has lost the fixed minimum rate. Can I simply copy the original formula from the Subtotal column S to correct that issue or does that bring about more issues with the new layout? Now, any time the rental period is less than a week on weekly or less than a month on monthly, it's back to calculating by the weeks and days instead of locking in the minimum weekly or monthly rate.
 
Upvote 0
That's good to hear. I went back to my earlier posts where "+1" was first introduced (that began in post #9)...and the +1 should appear in the column J,K, and L formulas. It sounds like you have that issue resolved.

As early as post #6, I had included MAX(IF(I18="Months",P18,Q18) in the Subtotal formula. But I recently deleted the MAX portion of the statement because I couldn't recall the original idea behind it. And now you've just reminded me:biggrin: Yes, adding that portion back in is fine. That enforces a minimum charge. The weekly rate (if "Weeks" is the basis for the estimate) or the monthly rate (if "Months") is compared to the actual SUMPRODUCT of rates and time breakdowns (m/w/d)...and the MAX is chosen, thereby ensuring a charge for a minimum of 1 week or 1 month. Here is the version incorporating this:
mrexcel_20220406.xlsx
ABCDEFGHIJKLMNOPQRST
16OriginalConditional
17Date RangeDescriptionQtyUnit RateWeeksItem SubtotalTerms: WeeksNum MonthsNum WeeksNum DaysNum MonthsNum WeeksNum DaysMonthly RateWeekly RateDaily RateSubtotalRental Period
18Computer Monitor12006d200.00Weeks006006 200.0028.57200.000m,0w,6d
19Speaker Set2506d100.00Weeks006006 50.007.14100.000m,0w,6d
20Start DateKeyboard & Mouse Set1206d20.00Weeks006006 20.002.8620.000m,0w,6d
217/1/22Computer Tower15006d500.00Weeks006006 500.0071.43500.000m,0w,6d
22End Date              
237/6/22              
24inclusive              
25              
26              
27Subtotal820.00
28Discount10.0%
29Net Amount738.00
30TOTAL AMOUNT738.00
Lil Stinker
Cell Formulas
RangeFormula
I17I17="Terms: "&$E17
I18:I26I18=IF(ISBLANK(C18),"",SUBSTITUTE(I$17,"Terms: ",""))
J18:J26J18=IF(ISBLANK(C18),"",IF(I18="Months",DATEDIF($A$21,$A$23+1,"M"),0))
K18:K26K18=IF(ISBLANK(C18),"",QUOTIENT(DATEDIF(EDATE($A$21,J18),$A$23+1,"D"),7))
L18:L26L18=IF(ISBLANK(C18),"",DATEDIF(EDATE($A$21,J18),$A$23+1,"D")-7*K18)
M18:M26M18=IF(ISBLANK(C18),"",IF(AND(I18="Months",K18=4),J18+1,J18))
N18:N26N18=IF(ISBLANK(C18),"",IF(AND(I18="Months",K18=4),0,K18))
O18:O26O18=IF(ISBLANK(C18),"",IF(AND(I18="Months",K18=4),0,L18))
P18:P26P18=IF(ISBLANK(C18),"",IF(I18="Months",D18,""))
Q18:Q26Q18=IF(ISBLANK(C18),"",IF(I18="Months",ROUND(D18/4,2),D18))
R18:R26R18=IF(ISBLANK(C18),"",(ROUND(Q18/7,2)))
S18:S26S18=IF(ISBLANK(C18),"",C18*MAX(IF(I18="Months",P18,Q18),SUMPRODUCT(M18:O18,P18:R18)))
T18:T26T18=IF(ISBLANK(C18),"",M18&"m,"&N18&"w,"&O18&"d")
E18:E26E18=IF($B18="","",SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(T18,"0m,",""),"0w,",""),",0d",""))
F18:F26F18=S18
F27F27=SUBTOTAL(109,F18:F26)
F29F29=F27*(1-F28)
F30F30=F29
Cells with Data Validation
CellAllowCriteria
E17ListMonths,Weeks
 
Upvote 0
Solution
Fantastic! This is great work, Kirk! Thank you so much for your time and patience.
I will start putting this through more rigorous testing using quotes with varying rates, dates and rental terms today. I'll let you know if I come across anything unusual but otherwise, I think everything is spot on.

Thanks again!
 
Upvote 0
That's great! Once you're satisfied that everything is working as expected, you may want to prevent editing on your cells containing formulas and protect the worksheet. Thanks for the good news...and I'm happy to help.
 
Upvote 0
Just stumbled on an anomaly that I cannot figure out. It's a bit of devil's advocate because this isn't something we would ever do but when I plugged in Start Date: 8/2/22, End Date: 10/15/22 everything calculated as expected when E17 had "Months" selected. However, when I selected "Weeks" in E17, column E resulted in 15d, instead of 10w, 5d.

When I tried a different set of dates, specifically 5/24/22 to 10/18/22, and selected "Weeks", it correctly displayed 21w,1d.

Now, if E18:E26 is simply copying T18:T26 and substituting 0 values for blanks... where in the world did it decide to convert 10w,5d to 15d?

Like I said, it's not important because we would never quote anything above a month at a weekly term... I just found it bizarre.
 
Upvote 0
Oh...I see the issue. The time components break down just fine. The only issue is the final formatting of the display where the SUBSTITUTE function is involved. 10w,5d --> 15d when the text string "0w," is stripped out and replaced with a blank...which is one of the things performed by the SUBSTITUTE formula. Similar problems will occur with 10m rentals (the 0m, will be removed), 10w or 20w or 30w rentals, etc. As you say, most (all?) of these aren't realistic because of how you structure the rentals, but it would be nice to clean this up. I'll have a closer look.
 
Last edited:
Upvote 0
This version does all of the Rental Period text string construction in the T column. It's messy because it needs to determine whether to use a comma or not, and that depends on whether other values are present. Excel 365 has a nifty TEXTJOIN function that would make this much easier, but for now, this should work:
mrexcel_20220406.xlsx
ABCDEFGHIJKLMNOPQRST
16OriginalConditional
17Date RangeDescriptionQtyUnit RateMonthsItem SubtotalTerms: MonthsNum MonthsNum WeeksNum DaysNum MonthsNum WeeksNum DaysMonthly RateWeekly RateDaily RateSubtotalRental Period
18Computer Monitor12004m,3w,4d978.56Months434434200.0050.007.14978.564m,3w,4d
19Speaker Set2504m,3w,4d489.32Months43443450.0012.501.79489.324m,3w,4d
20Start DateKeyboard & Mouse Set1204m,3w,4d97.84Months43443420.005.000.7197.844m,3w,4d
218/2/22Computer Tower15004m,3w,4d2446.44Months434434500.00125.0017.862446.444m,3w,4d
22End Date              
2312/26/22              
24inclusive              
25              
26              
27Subtotal4012.16
28Discount10.0%
29Net Amount3610.94
30TOTAL AMOUNT3610.94
Lil Stinker
Cell Formulas
RangeFormula
I17I17="Terms: "&$E17
I18:I26I18=IF(ISBLANK(C18),"",SUBSTITUTE(I$17,"Terms: ",""))
J18:J26J18=IF(ISBLANK(C18),"",IF(I18="Months",DATEDIF($A$21,$A$23+1,"M"),0))
K18:K26K18=IF(ISBLANK(C18),"",QUOTIENT(DATEDIF(EDATE($A$21,J18),$A$23+1,"D"),7))
L18:L26L18=IF(ISBLANK(C18),"",DATEDIF(EDATE($A$21,J18),$A$23+1,"D")-7*K18)
M18:M26M18=IF(ISBLANK(C18),"",IF(AND(I18="Months",K18=4),J18+1,J18))
N18:N26N18=IF(ISBLANK(C18),"",IF(AND(I18="Months",K18=4),0,K18))
O18:O26O18=IF(ISBLANK(C18),"",IF(AND(I18="Months",K18=4),0,L18))
P18:P26P18=IF(ISBLANK(C18),"",IF(I18="Months",D18,""))
Q18:Q26Q18=IF(ISBLANK(C18),"",IF(I18="Months",ROUND(D18/4,2),D18))
R18:R26R18=IF(ISBLANK(C18),"",(ROUND(Q18/7,2)))
S18:S26S18=IF(ISBLANK(C18),"",C18*MAX(IF(I18="Months",P18,Q18),SUMPRODUCT(M18:O18,P18:R18)))
T18:T26T18=IF(ISBLANK(C18),"",IF(M18<>0,M18&IF(AND(N18=0,O18=0),"m","m,"),"")&IF(N18<>0,N18&IF(O18=0,"w","w,"),"")&IF(O18<>0,O18&"d",""))
E18:E26E18=T18
F18:F26F18=S18
F27F27=SUBTOTAL(109,F18:F26)
F29F29=F27*(1-F28)
F30F30=F29
Cells with Data Validation
CellAllowCriteria
E17ListMonths,Weeks
 
Upvote 0

Forum statistics

Threads
1,223,903
Messages
6,175,284
Members
452,630
Latest member
OdubiYouth

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