1

My SQL query is not very complex. LeftOverMonthlyIncome is a variable calculated in the spreadsheet.

SELECT CounterOfferLineAmount 
FROM CounterOfferLine
WHERE MinLeftOverIncomeAmount <= LeftOverMonthlyIncome 
AND MaxLeftOverIncomeAmount >= LeftOverMonthlyIncome

Basically, "Give me the CounterOfferLine where LeftOverMonthlyIncome is between MinLeftOverIncome and MaxLeftOverIncome".

I've defined a table in Excel that has this structure:

MinLeftOverIncomeAmount __MaxLeftOverIncomeAmount __CounterOfferLineAmount<br/>
0__________________________30___________________0
30_________________________35___________________600
35_________________________40___________________700
40_________________________45___________________800
45_________________________50___________________900
50_________________________55___________________1000

If LeftOverMonthlyIncome is 43 then the CounterOfferLine should be 800 (43 >= 40 and 43 <= 45 that equates to 800)

How do I convert this into an Excel function? Is this a VLookup, Lookup, If, AND, Match, Index?

1
  • This is one calculation in a larger set of calculations. This will help others estimate what they SHOULD get when the larger process runs. Can't run the SQL because it's from production and would slow the system given the number of people running it. Commented Mar 30, 2018 at 17:34

1 Answer 1

1

You can search for the nearest value with VLOOKUP (vertical lookup):

=VLOOKUP(B11, B3:D8, 3, TRUE)

Where B11 is the value to look up, B3:D8 the matrix with values, 3 the column to select (CounterOfferLineAmount). The last parameter is the "range lookup" option. When set to TRUE or omitted,

If an exact match is not found, the next largest value that is less than lookup_value is returned.

VLOOKUP requires the list to be sorted.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.