LOOKUPVALUE with closest value

mrshl9898

Well-known Member
Joined
Feb 6, 2012
Messages
1,951
Hi all,

I'm needing to lookup a value from another table. The below could match 6 rows though.

=LOOKUPVALUE('RATE CARD'[value],'RATE CARD'[Origin],DELIVERIES[PickupResponsibleBranchCode],'RATE CARD'[ToLocation],DELIVERIES[ToRatingLocation])

The key here would be 'RATE CARD'[BreakPoint]

breakpointvalue
10000.2583
120000.237
2500.3915
5000.2912
30000.2457
9999990.237


These figures are the maximum in a range of weights, 250 is 0-250, 500 is 251-500 etc...

If I want to return a match for 375 (0.2912), what do I need to add to the Formula? Keeping in mind these numbers will change from time to time, so I need the closest greater than result.

The kilos are found in DELIVERIES[ChargeWeight].



Many thanks for any help here.
 

Excel Facts

Can you sort left to right?
To sort left-to-right, use the Sort dialog box. Click Options. Choose "Sort left to right"
Hi

My solution is based on the following spreadsheet layout of data and you can modify it to suit your situation.

1583885086715.png


Organise breakpoints in ascending order as shown above

Enter the following formula in C13


=INDEX($C$3:$C$8,MATCH(B13,$B$3:$B$8,1)+1)

Kind regards

Saba
 
Upvote 0
Maybe this measure will help :)
It should work in the same manner as Excel's approximate match.

VBA Code:
mLookup =
    var vSearch = 375
    var vLower = CALCULATE(MAX('RATE CARD'[breakpoint]), FILTER('RATE CARD', 'RATE CARD'[breakpoint] <= vSearch))
    var vHigher = CALCULATE(MIN('RATE CARD'[breakpoint]), FILTER('RATE CARD', 'RATE CARD'[breakpoint] >= vSearch))
return
    IF(ABS(vSearch - vLower) <= ABS(vSearch - vHigher),
        LOOKUPVALUE('RATE CARD'[value], 'RATE CARD'[breakpoint], vLower),
        LOOKUPVALUE('RATE CARD'[value], 'RATE CARD'[breakpoint], vHigher))

1583962132177.png
 
Upvote 0

Forum statistics

Threads
1,223,799
Messages
6,174,669
Members
452,576
Latest member
AlexG_UK

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