Home > Mobile >  How to use an if condition with vlookup?
How to use an if condition with vlookup?

Time:10-19

I am working with some data in google spreadsheets, but I'm having problems with vlookup. I'm trying to get the district of an adress by the name of the street and the house's number. The problem is that vlookup stops on the first row, and some streets are so big that they below for more than one district.

In this example, i want to do a vlookup that returns the district D if my adress is street A number 15. Can someone help me? thanks.

Street Start_Number End_Number District
A 0 10 C
A 11 20 D
B 0 10 C

CodePudding user response:

Try QUERY() instead of VLOOKUP():

=QUERY(A:D, "
    SELECT
        D
    WHERE
        A = 'A'
        AND B <= 15
        AND C >= 15
    LABEL
        D ''
    ", 1)

Swap out the 'A' and 15 with cell references if you want it to be dynamic.

  • Related