Adding another condition to IF(AND) formula

wynandbecker

New Member
Joined
Feb 23, 2021
Messages
19
Office Version
  1. 365
Platform
  1. Windows
The sheet is in my master quote spreadsheet, the line in question calculates the price I'm renting out a lowbed truck for.
The truck has a minimum dayrate (column SHIFTS), and then also columns for the amount of kilometers the client will need to use it for.
The formula in the TOTAL cell compares (SHIFT x dayrate) total, to the (Kilometers x kilometer rate) total, and fills in whichever one is higher.
My problem is that if the user does not enter a value into SHIFTS cell, the TOTAL cell gets the Kilometer calculation, even if that value is lower than the minimum rate would have been.

Is there a way to force users to have something in SHIFTS cell? Or even better if the formula in TOTAL could have another condition to make sure it can never be less than the minimum rate?

The line in question is 24

COSTMASTERv9.0_MAY2024_COPY1.xlsx
ABCDEFGHIJKLMN
9PASTEL CODEDESCRIPTIONNR OF VEHICLESTOTAL SHIFTSTOTAL NO-FREIGHT KMTOTAL FREIGHT KMRATELINE
10DAYKMFREIGHT KMTOTAL
11COSTSELLINGCOSTSELLINGCOSTSELLINGCOSTSELLING
12LDV DC KATHU / SISHEN11R1,242.09R4.84R0.00R1,242.09
13LDV DC BEESHOEKR1,605.09R4.84R0.00R0.00
14LDV SC BEESHOEKR1,025.23R4.84R0.00R0.00
15LDV DC KOLOMELAR1,863.14R4.84R0.00R0.00
16LDV DC SOUTH32#N/AR9.28R0.00#N/A
17LDV LONG DISTANCE11R1,242.09R4.84R0.00R1,242.09
18REC0213.2T TATA WITH HIGH-UPR2,341.96R9.28R0.00R0.00
19LIVING OUT ALLOWANCESET MARKUPR297.00R424.71R0.00R0.00
20ACCOMODATION1.3R935.00R1,337.05R0.00R0.00
21COURIER COSTPACKAGE SIZEN/AR0.00
22TOTAL MISCR0.00#N/A
23TRUCKS (DRIVER INCLUDED)PERMITTOTAL SHIFTSTOTAL NO-FREIGHT KMTOTAL FREIGHT KMTOTAL KM
24REC001LOWBED 44T DAY RATE INCLUDES 250KM100100200R8,542.88R23.76R31.68R26.40R33.00R5,016.00R6,468.00
25REC033LOWBED 44T DAY RATE INCLUDES 250KM100100200R8,542.88R23.76R31.68R26.40R33.00R5,016.00R6,468.00
26REC043RENTAL OF FAW TRUCK 15TON 6.2T HI-AB100100200R5,250.00R20.99R25.17R22.90R31.46R4,389.00R5,663.00
27REC063RENTAL OF ISUZU TRUCK 14.2T, DROP SIDE100100200R4,545.00R20.99R25.17R22.90R31.46R4,389.00R5,663.00
28REC109RENTAL OF ISUZU TRUCK 14.2T, DROP SIDE100100200R4,545.00R20.99R25.17R22.90R31.46R4,389.00R5,663.00
29FREIGHT INSURANCE (COST)R0.00
30TOTAL LOWBEDR23,199.00R29,925.00
TRANSPORT
Cell Formulas
RangeFormula
H16,H18H16=INDEX(RENTAL_PRICELIST!$C$51:$AU$62,MATCH(A16,RENTAL_PRICELIST!$A$51:$A$62,0),MATCH(LABOUR!$A$1,RENTAL_PRICELIST!$C$1:$AU$1,0))
M12:M18M12=SUM(C12*D12*G12)+C12*D12*E12*I12
M19:M20M19=SUM(C19*D19*G19)
N12:N18N12=SUM(C12*D12*H12)+(C12*D12*E12*J12)
N19:N20N19=SUM(C19*D19*H19)
N21N21=INDEX('CLIENT DATA'!D2:D9,MATCH(K21,'CLIENT DATA'!C2:C9,0))
M22M22=SUM(M12:M20)
N22N22=SUM(N12:N21)
G24:G28G24=SUM(E24:F24)
M24:M28M24=IF(AND((E24*I24+F24*K24)<D24*G24,(E24*I24+F24*K24)>0),(D24*G24)+C24,(E24*I24+F24*K24+C24))
N24:N28N24=IF(AND((E24*J24+F24*L24)<D24*H24,(E24*J24+F24*L24)>0),(D24*H24)+(C24*1.1),(E24*J24+F24*L24)+(C24*1.1))
N29N29=M29*1.1
M30:N30M30=SUM(M24:M29)
Cells with Data Validation
CellAllowCriteria
D24Whole numberbetween 1 and 100
F20:F21List='CLIENT DATA'!$C$65:$C$74
K21:L21List='CLIENT DATA'!$C$2:$C$9
 

Excel Facts

Add Bullets to Range
Select range. Press Ctrl+1. On Number tab, choose Custom. Type Alt+7 then space then @ sign (using 7 on numeric keypad)
(E24*J24+F24*L24)+(C24*1.1)
is that the formula which calculates the cost ?
if so , just change that to a MAX() and add the minimum cost
=MAX((E24*J24+F24*L24)+(C24*1.1),minimum value)

i wasnt sure where you minimum rate was in the spreadsheet

so if a cell , you can add that - or a fixed amount
 
Upvote 0
(E24*J24+F24*L24)+(C24*1.1) is TOTAL KM + TOTAL FREIGHT KM, and the value in TOTAL must be that, IF it is higher than the value of SHIFTS x DAYRATE

The complete formula is
=IF(AND((E24*J24+F24*L24)<D24*H24,(E24*J24+F24*L24)>0),(D24*H24)+(C24*1.1),(E24*J24+F24*L24)+(C24*1.1)) , can I still add MAX in there?
 
Upvote 0
yes,
BUT in row 24 , I dont see any shift entered , so cannot use shift * dayrate

thats the test
=AND((E24*J24+F24*L24)<D24*H24,(E24*J24+F24*L24)>0)
and if true , then
(D24*H24)+(C24*1.1)
if false
(E24*J24+F24*L24)+(C24*1.1))
you can add the MAX to both of those , so it can never be below whatever you set as the minimum

so

=IF( AND((E24*J24+F24*L24)<D24*H24,(E24*J24+F24*L24)>0) , MAX( (D24*H24)+(C24*1.1) , minimum cost ) , MAX ( (E24*J24+F24*L24)+(C24*1.1) , minimum cost ) )
 
Upvote 0
Thanks man, that works it never goes below minimum. Gives me a new problem though, if there are no lowbeds on the quote, and that section is just left blank - i still end up with the minimum amount in the TOTAL cell now.
 
Upvote 0
just add at the beginning
=IF( cell with shifts in = 0 , "Error Enter Shifts", IF ( your formula .... )
the 0 will pickup cells that are blank or have a zero entry

or if never going to be entered as zero in error then
=IF( cell with shifts in = "" , "Error Enter Shifts", IF ( your formula .... )
 
Upvote 0

Forum statistics

Threads
1,223,885
Messages
6,175,184
Members
452,615
Latest member
bogeys2birdies

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