Sumproduct problem

bezmon1985

New Member
Joined
Mar 7, 2018
Messages
3
hiya

having a little trouble with a Sumproduct formula. Below is what i would like to achieve

Cost of journey determine by length

0-29 Miles @ £1.7
30-50 Miles @ £1.6
51-80 Miles @ £1.4
80+ Miles @ £1.3

i have entered the formula (c21 being where i enter the mileage)

=SUMPRODUCT(--(C21>{0,29,30,50,51,80,81,9999}),--(C21-{0,29,30,50,51,80,81,9999}),{1.7,-0.1,-0.3,-0.4})

but it only seems to bring the correct amount upto 30 miles thereafter the result is incorrect!

Any help would be reatly appreciated

Many thanks for taking the time to look over my woes

Bezmon1985
 

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.
How about this...

Code:
=LOOKUP(C21,{0,29,50,80},{1.7,1.6,1.4,1.3})*C21
 
Upvote 0
Small adjustment. I doubled checked. Everything seems to match now.

Code:
=LOOKUP(C21,{0,30,51,80},{1.7,1.6,1.4,1.3})*C21
 
Upvote 0
Hi,

If I understand correctly, don't think SUMPRODUCT was the correct approach to begin with, and the LOOKUP will only give a linear result.
I'm assuming what you have is a Tiered Charge/Cost Table, this is one approach, I may be wrong in my assumption:
Need adjustment to my formula, post back soon.
 
Last edited:
Upvote 0
Hi,

If I understand correctly, don't think SUMPRODUCT was the correct approach to begin with, and the LOOKUP will only give a linear result.
I'm assuming what you have is a Tiered Charge/Cost Table, this is one approach, I may be wrong in my assumption:
Need adjustment to my formula, post back soon.

Here you go:


Book1
BCD
15FromToCost
160291.7
1730501.6
1851801.4
19811.3
20
2181126.2
Sheet16
Cell Formulas
RangeFormula
D21=SUM(MEDIAN(B16,C16,C21)*D16,MEDIAN(0,C17-B17+1,C21-C16)*D17,MEDIAN(0,C18-B18+1,C21-C17)*D18,MAX(0,C21-C18,0)*D19)
 
Last edited:
Upvote 0
I see what you're saying jtakw. If that is the case, here is another way of doing it that will get the same result.

Code:
=SUMPRODUCT(LOOKUP(ROW(INDIRECT("1:"&C21)),{0,30,51,81},{1.7,1.6,1.4,1.3}))
 
Upvote 0
hi all

thanks for all your help, have manged to get a result using LOOKUP by creating a manual table with all result listed entered manually

cheers again

Bezmon1985
 
Upvote 0
You're welcome, welcome to the forum, glad you sorted it out.
 
Upvote 0

Excel 2010
ABCDEFG
181126.501.71.7
2126.5301.6-0.1
3511.4-0.2
4801.3-0.1
5
4a
Cell Formulas
RangeFormula
B1= SUMPRODUCT(--(A1>E1:E4),A1-E1:E4,G1:G4)
B2= SUMPRODUCT(--(A1>{0;30;51;80}),A1-{0;30;51;80},{1.7;-0.1;-0.2;-0.1})
 
Last edited:
Upvote 0

Forum statistics

Threads
1,215,523
Messages
6,125,318
Members
449,218
Latest member
Excel Master

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