Hlookup and Interpolation

Tennisguuy

Well-known Member
Joined
Oct 17, 2007
Messages
564
Office Version
  1. 2016
Platform
  1. Windows
I have a situation with a table that I am using a hlookup. The problem is the lookup value might not be in the table and I will need to interpolate for the value that is not in the table.

Below is a copy of the table

10,000 15,000 25,000 50,000 75,000 100,000 150,000 250,000 500,000 750,000 1,000,000
0.007 0.006 0.005 0.004 0.003 0.003 0.002 0.002 0.04 0.05 0.055
0.002 0.001 0.001 0.001 0.001 0.001 0.001 0.002 0.04 0.05 0.055
0.003 0.002 0.002 0.002 0.001 0.001 0.001 0.002 0.04 0.05 0.055
0.001 0.001 0.001 0.001 0.001 0.001 0.001 0.002 0.04 0.05 0.055
0.001 0.001 0.001 0.001 0.001 0.001 0.001 0.002 0.04 0.05 0.055
0.001 0.001 0.001 0.001 0.001 0.001 0.001 0.002 0.04 0.05 0.055

The table is in rows Q7:AA13.

I used the following formula in cell D9 IF(B5<=4,HLOOKUP(B9,'Crime Rating'!Q7:AA13,2,FALSE)) and it works but again my problem is when the value in B9 is not in the table I will get a #N/A error. For example if the value in cell B9 is 30,000

The values in the individual row depend are in column A I was just going to copy down the formula to change the lookup row. for example in row 10 the formula would be IF(B5<=4,HLOOKUP(B9,'Crime Rating'!Q7:AA13,3,FALSE))

If interpolating within multiple row is too complex I can make a separate table with just one row of data for each of the value in column A.
 
Well, I was thinking you already knew how to do this. However, in order to get help you have to define how to do the calculations.
My suggestion above: use a Rule of Three

M.
 
Upvote 0

Excel Facts

Excel Wisdom
Using a mouse in Excel is the work equivalent of wearing a lanyard when you first get to college
Complementing my previous post
I believe it will be a long formula, not difficult, but boring to do...Try to create it, and get back if you have problems.

M.
 
Upvote 0
A suggestion


A
B
C
D
1
Rule of Three​
Result​
2
25000​
-0,001​
0,0048​
3
5000​
-0,0002​

Where
A2 = T7-S7 (the value above 30000 - the value below 30000 in the range Q7:AA7)
A3 = B9 -S7
B2: 0.004 - 0.005 (value in row 2 corresponds to 50000 - value in row 2 corresponds to 25000)
B3: =A3*B2/A2

Result in D2
=HLOOKUP(B9,'Crime Rating'!$Q$7:$AA$13,2)+B3

M.
 
Upvote 0
Marco thank and yes I know how to do an interpolation if I know where the unknown value would fall. In this example of 30,000. However when the value is not listed in the chart and I would need to interpolate I was wondering if there was a formula that could interpret the value without me having to do a manual interpolation. In one instance the value in B9 could be 30,000 or 600,000. What is a Rule of Three.
 
Upvote 0
Of course i'm not suggesting you do the interpolation manually.
What i'm trying to say is:
Try to create a formula that does the interpolation, i.e., gets the values in A2, A3, B2, B3 in my example post above (Rule of Three)
For example:
To get the value in A2 (above 30000 - below B9) try
=INDEX('Crime Rating'!$Q$7:$AA$7,MATCH(B9,'Crime Rating'!$Q$7:$AA$7)+1)-INDEX('Crime Rating'!$Q$7:$AA$7,MATCH(B9,'Crime Rating'!$Q$7:$AA$7))

Where:
the part in Blue corresponds to the value above
the part in Black corresponds to the value below

Then in the original formula in D2
=A3*B2/A2
substitutes A2 by the expression above
=A3*B2/(INDEX('Crime Rating'!$Q$7:$AA$7,MATCH(B9,'Crime Rating'!$Q$7:$AA$7)+1)-INDEX('Crime Rating'!$Q$7:$AA$7,MATCH(B9,'Crime Rating'!$Q$7:$AA$7)))

Try the same to get the values in A3 and in B2 - doing so you can create the final formula step by step.

As i said, if you have problems i'll try to help, but try to do it by yourself - i'm also involved in others threads.

M.
 
Last edited:
Upvote 0
A neat solution using some helper cells to make the understanding and maintenance easier.


B
C
D
E
F
G
H
I
J
8
SearchValue​
SearchRow​
ExactMatch?​
ValueAbove​
Corresp. in Row​
ValueBelow​
Corresp. in Row​
Value to add​
Result​
9
25000​
2​
Yes​
0​
0,005​
10
30000​
2​
No​
50000​
0,004​
25000​
0,005​
-0,0002​
0,0048​
11

<tbody>
</tbody>


Search value in B9

Row of interest in C9

Formula in D9 copied down
=IF(ISNUMBER(MATCH(B9,'Crime Rating'!$Q$7:$AA$7,0)),"Yes","No")

Formula in E9 copied down
=IF(D9="Yes","",INDEX('Crime Rating'!$Q$7:$AA$7,MATCH(B9,'Crime Rating'!$Q$7:$AA$7)+1))

Formula in F9 copied down
=IF(D9="Yes","",INDEX('Crime Rating'!$Q$7:$AA$13,C9,MATCH(B9,'Crime Rating'!$Q$7:$AA$7)+1))

Formula in G9 copied down
=IF(D9="Yes","",INDEX('Crime Rating'!$Q$7:$AA$7,MATCH(B9,'Crime Rating'!$Q$7:$AA$7)))

Formula in H9 copied down
=IF(D9="Yes","",INDEX('Crime Rating'!$Q$7:$AA$13,C9,MATCH(B9,'Crime Rating'!$Q$7:$AA$7)))

Formula in I9 copied down
=IF(D9="Yes",0,(B9-G9)*(F9-H9)/G9)

At last...formula in J9 copied down
=HLOOKUP(B9,'Crime Rating'!$Q$7:$AA$13,C9)+I9

M.
 
Upvote 0
Marco thanks for all of your help. Really appreciate it.

You are very welcome.

Remark: reviewing my message above I noticed that I made a mistake in the formula in I9. By chance the result of the example would be the same, but the correct formula in I9 should be:
=IF(D9="Yes",0,(B9-G9)*(F9-H9)/(E9-G9))

M.
ps: my name is not Marco
 
Last edited:
Upvote 0

Forum statistics

Threads
1,215,234
Messages
6,123,773
Members
449,123
Latest member
StorageQueen24

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