LOOKUP function not giving expected results - excel

I am having a problem with the LOOKUP function.
To test some things, I entered the following function
=LOOKUP(4.19, $B$2:$B$6, $C$2:$C$6)
And on every line, it gives me a different answer. I don't know what is the problem with it because it just gives me the wrong answer. It should say "blue".

The lookup value must be (always) in the first column of the lookup table. So, if you are looking for 4.19 (which is in the right-most-column) in order to return a value from a column further to the left then you'll have to change to INDEX/MATCH like so:
=Index($C$2:$C$6,Match(4.19, $B$2:$B$6,0))

With LOOKUP the values you are searching in must be in descending order. If you want to keep the order as is, you might want to use INDEX/MATCH functions.

With the third argument you tell the function what the output should be if the first argument( 4.19) is valid. since you enterd a range of cells, the output differs. Also if you are searching for an exact value you should add a further argument at the end of the function
=VLOOKUP(4.19, $B$2:$B$6, D1, FALSE)

Related

Lookup / Vlookup not returning correct value

Either I use Lookup or Vlookup, the result is wrong if my lookup value is from a formula.
It is correct if I type the lookup value. I'm expecting 5 as result, which I was able to get in first row because I typed '80%'. However in second row, I get 4 when I reference it to the computed 80%:
But I need to have it look up via a formula, any help please?
While rounding solved the problem for you, it didn't explain where the problem started.
Judging by your examples matching the correct values when typed and wrong if calculated, I conclude the values in A1:B6 are not percentages, but text strings. Using round on those solves your problem, since round converts the string to a number (if it can).
See explanation in this screenshot:

LOOKUP function gives N/A answer in some selected list options

I have 3 columns in excel first one is normal text second one is the list where we can select different options and the third one is the LOOKUP function associated with the list so according to option I select it changes the value.
In the third column I first two-row is working properly but in the third one when I select the third option I got N/A answer I am not sure what is the problem because I provided the proper location.
Here is my EXCEL FILE
here is my lookup command
=LOOKUP(B5,D33:D35,E33:E35)
Please help me if you need any information from my side please comment. Thank You
LOOKUP function does approximate match but judging from your file I think you want exact match. Please switch to VLOOKUP and your function should be something like the following in Cell C5 which shall return 26.
=VLOOKUP(B5,D33:E35,2,FALSE)
As explained in this article Excel LOOKUP Function:
When lookup_value is less than all (i.e. the first) value in lookup_vector, LOOKUP returns #N/A.
In the above example, Bechalor Degree or Above is actually less than High School which is the first value in your look up range so it explained why your command returned #N/A.
Another way to solve the issue is to sort your look up range alphabetically (by Column D) then your LOOKUP function will return the desired figure from Column E.

Workaround for named range Search function issue in Excel

I have a bank export of Credit card vendors. As these vary, I use unique strings contained in each to identify them. For example here is a lookup table excerpt.
First Lookup
I then apply a formula =INDEX(First_level,MATCH(TRUE,ISNUMBER(SEARCH(Keywords,C3374)),0)) to produce this:
First calc
I found this formula here https://exceljet.net/formula/get-first-match-cell-contains
Then I reapply the formula to the result ie the First_Level using this formula =INDEX(Second_Level,MATCH(TRUE,ISNUMBER(SEARCH(Frst_Lev_Check,H44)),0)) with this Lookup.
Second Lookup
Most of the time it works, but for this I get the following
Second calc, where the first level classification is correct, but the second level one is completely wrong.
When I've gone into the depths of the formula, the issue is that the Search function is returning the wrong value.
This appears to be a known issue: https://answers.microsoft.com/en-us/msoffice/forum/all/how-to-use-named-range-in-search-function/14c8c989-bed0-48f9-bce0-c0894571b557
Ideas welcome on workarounds/how to solve the problem.
Cheers Jon
Would you consider:
=MATCH("Apple",List)
and
=MATCH("Pear",List)
to return 1 and 2 respectively.
A couple of things in regards to your question:
The correct syntax for search is =SEARCH(find_text,within_text), so the correct formula would be =SEARCH("Pear",List).
The reason why you are getting the #Value is, because you are applying search to a range, but the function is only intended for cells.
The best ways to see if a value exists in a range are the countif and match function:
The countif function shows you how many times the a value is in a range:
The match function shows you in which row the the first value is:

Excel VLOOKUP returning same value in all rows

The vlookup function appears to be broken. It is returning the same value for all lookups, but it should not.
I have it set like so:
=VLOOKUP(A3, Asset_Mapping!A$2:B$673, 1)
Where the lookup value is in the B column and the result is in the A column.
I use the $ so the rows are not auto-updated to A3:B674 etc as I paste the formula down the rows. However, even if I manually enter that formula into the next row, it is not finding the correct value.
IF i remove the "$", the correct values are found for the first rows where the values fall within the modified range (e.g. Asset_Mapping!A3:B674) but eventually as expected it stops finding the values as the range is invalid.
What am I doing incorrectly here? I have formulas set to auto-calculate.
Without testing on your actual data it's hard to confirm this will work but add the false parameter. This will find exact matches and not the first partial match.
=VLOOKUP(A3, Asset_Mapping!A$2:B$673, 1, false)
Collating the points together and clarifying the formula
Parameter 1: The value you are looking for
Parameter 2: The table with the data. First column is the value you are looking for.
Parameter 3: The column number of the value you want to show.
Parameter 4: If you want an exact match or partial match.
#Jeeped made the point of ordering data to get more reliable results. Good advice.
Andres has the right idea, but there is a faster way to fix the problem.
If it is returning the same value over and over again for your whole range, you probably have your Calculation Options set to "Manual".
Go into Formulas on the top ribbon and choose Calculation Options. There, you can change your calc method to "Automatic".
Also lookup value must be in first column.
Where the lookup value is in the B column and the result is in the A column.
VLOOKUP always lookup in the left-most column and returns a value from the column number specified. If you want to reverse the lookup/return order then use INDEX(..., MATCH(...))
=INDEX(Asset_Mapping!A$2:A$673, MATCH(A3, Asset_Mapping!B$2:B$673, 0))
Note that you were using a sorted, binary lookup; I've changed this to an exact match lookup which does not require sorted data.
Just in case adding a solution to this topic.
Don't know why in big tables Vlookup and Index+Match tend to show just the value of the first result in all the other cells.
In my case to fix this, after I've copied the formula in the whole range, I choose any cell containing it, press F2 and then Enter. It kind of forces excel to process everything.
I've been working on this for a week with no results. I've created this same spreadsheet for another apartment community without any issues, but for some reason, I cannot get the proper results in this spreadsheet. I've tried vlookup as well, but that didn't help either. any more advice?
Formula
Result and lookup vectors

Excel 2003/2007 named formula appears to store only single value not range/array

Similar to a question by Stephen Roy April 26, 2013, answered by Barry Houdini. I have a named range per this generic formula
{=IFERROR(INDEX(Range,SMALL(IF(
MATCH(Range,Range,0)=ROW(INDIRECT("1:"&ROWS(Range))),
MATCH(Range,Range,0)),ROW(INDIRECT("1:"&ROWS(Range))))),"")}
[obviously in 2003 I don't use IFERROR()]
"Range" itself is a named array formula.
The formula is used to pull unique entries from a range and arrange them at the 'top' of another 'range'. However, INDEX() appears to 'store' only a single value, not the array expected. Barry talked about wrapping the ROW() in another function to lose the {array}. It looks as though the first ROW() returns multiple values and works fine, it's the last ROW() which seems to be reduced to the first array entry only, thereby causing INDEX() to return only a single value. However, instead of trying to store this in memory, I select a multi-cell range for output, and use CSE, it works perfectly well. But I don't want to have to do that.
I've tried messing around with INDIRECT(), but can't get that to work at all.
Grateful for your thoughts folks, ian taylor
This might work for you. To return a list of unique values given your range x for example:
=LOOKUP(SMALL(IF(MATCH(x,x,0)=ROW(INDIRECT("1:"&ROWS(x))),MATCH(x,x,0)),
ROW(INDIRECT("1:"&SUM(IF(FREQUENCY(MATCH(x,x,0),MATCH(x,x,0)),1))))),
ROW(INDIRECT("1:"&ROWS(x))),x)
You could define this as a name called Unique and use it in other formulas eg =COUNTIF(x,Unique) returns an array of frequencies.
Addendum
Regarding INDIRECT/INDEX/ROW etc. here's my 2c (see also here). Function inputs and outputs can essentially be divided into three cases: single values, arrays or references. If a function input argument takes single values by default and an array is specified, then the result depends on the type of output of the function. If the output type of the function is:
A) a single value - an array of values is returned, one for each input value. This is the case for most functions eg =LOOKUP({1;2},{1;2;3},{"a";"b";"c"}) returns {"a";"b"}.
B) a reference - an array of references is returned. This is the case for INDIRECT/OFFSET. eg =INDIRECT("A1:A"&ROW()) returns a single element array containing a reference but this can raise errors in many functions as the references are not converted to values by default.
C) an array - a value or array is returned based on the first input of the function if evaluated normally and entered into a single cell. Or else an array is returned based on the first result for each input if entered into multiple cells. This is the case for INDEX which may return an array if one of the arguments is zero. For example =INDEX({1,2;3,4},0,{1;2}) returns {1;3} when evaluated in the formula bar, but {1;2} when array-entered into cells.
In fact Excel uses a variant data type that can take on any of these types so the details are a little more complex than this. Also there is the ability to modify arguments in place which may be why for example VLOOKUP behave like case C with arrays in the first argument but case A with the third argument.
i tried this as a defined name say, "Unique_List" so that i can use it as a Data validation list, but when i add this defined name to the data validation list, it gives an error.
=LOOKUP(SMALL(IF(MATCH(x,x,0)=ROW(INDIRECT("1:"&ROWS(x))),MATCH(x,x,0)), ROW(INDIRECT("1:"&SUM(IF(FREQUENCY(MATCH(x,x,0),MATCH(x,x,0)),1))))), ROW(INDIRECT("1:"&ROWS(x))),x)
where x is my range.
i tried transposing this formula to get the values comma-separated rather than semicolon-separated, but data validation list doesnt seem to work.
=TRANSPOSE(LOOKUP(SMALL(IF(MATCH(x,x,0)=ROW(INDIRECT("1:"&ROWS(x))),MATCH(x,x,0)), ROW(INDIRECT("1:"&SUM(IF(FREQUENCY(MATCH(x,x,0),MATCH(x,x,0)),1))))), ROW(INDIRECT("1:"&ROWS(x))),x))
Kindly advice.

Resources