Calculate price for a driver based on distance

cool2005

New Member
Joined
Sep 22, 2022
Messages
5
Office Version
  1. 2016
Hi everyone,

Need your help if possible to create a spreadsheet in Excel 2016 that will calculate the price for my driver based on multiple conditions and driven distance:

For example if driver goes for 0-30km will get 10.50 dollars, if it drives between 31-50km will get 18 dollars, if will drive between 51-75KM will get 25 dollars and so on, 76-100 km will get 35 dollars. i was thinking to do it with a formula or make a table first in excel with this values and get the data from there.

basically what i need will be a table that contain name of the driver, driven kilometers and then i will get the price column automatically completed based on specific values:

if driver made 25 km column price will be autofilled with 10.50 dollars
if driver made 71 km will get 25 dollars automatically

i will only insert driven KM and price will be automatically calculated.
 

Excel Facts

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.
What amount for >100km? I assume it was 45
Assume A1 is driver name, B2 is km, C2 is amount
C2:
Code:
=LOOKUP(B2,{0,30,50,75,100},{10.5,18,25,35,45})
 
Upvote 0
If you are looking to just get the price based on the total distance, try something like this. If you are one of those who is very particular about precision, you can increase the precision by adding more zeroes to the 0.1 I used. But I guess you could just stick to this if you're using rounded distance.... like 31 (or 30), instead of 30.3 depending on what's your arrangement with your driver.

Excel Formula:
=LOOKUP(A1,{0;30;50;75;100}+0.1,{10.5;18;25;35;42.5})
 
Upvote 0
Thank you very much for your feedback.

I tried using:

=LOOKUP(B2,{0,30,50,75,100},{10.5,18,25,35,45})

but i get formula error. Is not cleat to me at this point, if i use input 28KM, would it autocomplete 10.5 dollars?

I don't need more decimals, it will be rounded distance and it will go up to 1500 km with different values.
 
Upvote 0
Thank you very much for your feedback.

I tried using:

=LOOKUP(B2,{0,30,50,75,100},{10.5,18,25,35,45})

but i get formula error. Is not cleat to me at this point, if i use input 28KM, would it autocomplete 10.5 dollars?

I don't need more decimals, it will be rounded distance and it will go up to 1500 km with different values.
Try to replace "," with ";"?
With more milestone up to 1500km, Its better to create a lookup table then using VLOOKUP or INDEX-MATCH
 
Upvote 0
There are 22 milestones to be filled in and goes up to 1500KM to be more precise. I tried also the following formula but still doesn't work:

1663834103951.png
 
Upvote 0
The two vectors in LOOKUP should be in same direction ("," for horizontal and ";" for vertical range)

=LOOKUP(B2,{0;30;50;75;100},{10.5;18;25;35;45})

or

=LOOKUP(B2,{0,30,50,75,100},{10.5,18,25,35,45})
 
Upvote 0
I tried to use for vertical range and i have the following sample table:

1663834731175.png


On D2 i have value 100 KM

I suspect is something related to syntax, if i look in excel i have the following sample for formula format:

1663834799784.png


So would be LOOKUP(lookup_value;lookup_vector;[result_vector] - its ; mandatory instead of , after first two elements?
 
Upvote 0

Forum statistics

Threads
1,224,835
Messages
6,181,245
Members
453,026
Latest member
cknader

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