Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

lookup function doesn't work with unsorted list

Why does this work, and looks up values correctly

enter image description here

but once i change the order of values, it produces incorrect values?

enter image description here

like image 317
jakub Avatar asked Sep 28 '14 16:09

jakub


People also ask

Does Vlookup work with unsorted data?

VLOOKUP Exact Match uses unsorted data in Excel. Based on how Excel works, VLookup doesn't need to be sorted, if the 4th parameter is FALSE. The 4th Parameter determines whether an approximate search is used or an exact match is used. by default true is used and an approximate search requires a sorted range.

Why Vlookup is not working in Google Sheets?

If is_sorted is set to TRUE or omitted, and the first column of the range is not in sorted order, an incorrect value might be returned. If VLOOKUP doesn't appear to be giving correct results, check that the last argument is set to FALSE . If the data is sorted and you need to optimize for performance, set it to TRUE .

What does the lookup function return if an exact match Cannot be made?

If an exact match is not found, the Lookup function will match the closest value below the lookup value.


1 Answers

If you read the notes on the LOOKUP function, it says:

The LOOKUP function will only work properly if data in search_range or search_result_array is sorted. Use VLOOKUP, HLOOKUP, or other related functions if data is not sorted.

Change your formula to use VLOOKUP as follows:

=VLOOKUP(D3, A1:B6, 2, FALSE)

Syntax:

VLOOKUP(search_key, range, index, [is_sorted])

search_key - The value to search for. For example, 42, "Cats", or I24.

range - The range to consider for the search. The first column in the range is searched for the key specified in search_key.

index - The column index of the value to be returned, where the first column in range is numbered 1.

is_sorted - [OPTIONAL - TRUE by default] - Indicates whether the column to be searched (the first column of the specified range) is sorted.

like image 173
Bill the Lizard Avatar answered Sep 21 '22 10:09

Bill the Lizard