Here is a simplified version. I was trying to match the shop grade from a given table to the data but it returned error, what's wrong with my vlookup function? I'm an Excel beginner.
The data:
The given table:
You are trying to match Column B so your lookup range should start with that:
=VLOOKUP(B2,Table!B2:C3,2,False)
Vlookup requires the first column to be the lookup column.
You have to look up by referencing the first column in the table. In this case, change B2 to A2 and it will work.
What is vlookup?
Does a lookup for a specified value in the left most column of a specified table(table_array) vertically from top to bottom and returns a value from one of the columns(column_index_number) of the table. Formula follows
VLOOKUP(lookup_value,table_array,column_index_number,[range_lookup])
These are common pitfalls with vlookup.
If table A is used to lookup and table B is getting populated with values
Lookup value is not first column of table array(table A)
Lookup column on table array is not sorted - sort using excel sort function in Data tab
Dragging the formula would have caused Table array to shift for each lookup in table B. E.g A1:C10 may become A2:C11 for second lookup and can result in #NA if lookup result falls in top rows which is missing. Use $A$1:$C$10 as lookup array table A to make sure that formula is not affected while dragging the cells. Alternately, naming table array can also be employed.
Range lookup true can result in getting invalid results even when no result is present in table A. Using range lookup false will be accurate in most cases.
Reference :
MS Office vlookup help
Named tables in Excel
Related
I am building an RFM table in excel, and want to lookup against a score table I created. Using row 3 as an example in the pic below, when I use the vlookup true function which is supposed to return a close match from the recency rankings table the vlookup is pulling in a 5 in column F, instead of a 1. I am not looking to do an exact match as that is not how this analysis is structured.
Any thoughts on why the true statement in the vlookup is not returning correct values? Any thoughts on how to fix would be appreciated.
enter image description here
When you use TRUE as the final parameter in VLOOKUP (for "approximate match"), Excel (for whatever reason) stipulates that the corresponding values in the first column of the lookup range must be in ascending order. The prompt as you're typing the formula notes this
Therefore, re-order your lookup table and then the VLOOKUP values should populate as you expect them to
I have a table in which multiple weeks of data is stored and I'm trying to return a value based on 2 criteria.
Column A of the data sheet contains the date the report was ran (Always on the same day of the week - 24/05/17, 31/05/17 etc)
I've managed to return the value of column H by using an array formula, based on a cell value (Date) in ''Issues Data Quality Overview'!$B$4' using the following formula:
{=IFERROR(INDEX('Issues Log'!$H$1:$H$20000,SMALL(IF('Issues Data Quality Overview'!$B$4='Issues Log'!$A$1:$A$20000,ROW('Issues Log'!$A$1:$A$20000)-MIN(ROW('Issues Log'!$A$1:$A$20000))+1,""), ROW(A2))),"")}
That returns a value such as "IID-10225-22".
Problem:
Now I need to look up that value in the same table, based on a date in another cell, and return column X. (essentially adding the returned value as a criteria).
In all honesty I'm lost as to how I'd do this.
#Matthew. I understand your formula gives the list of values in column H with column A values matching 'Issues Data Quality Overview'!$B$4 in an ordered list.
Does your Issues Log, column H have multiple occurrence of the same value? (example: IID-10255-22 can have a value in Issues Log, column A that is not the same value as 'Issues Data Quality Overview'!$B$4).
If not, it doesn't make sense to use the result as a lookup value to get column X, you can simply change the code to:
{=IFERROR(INDEX('Issues Log'!$X$1:$X$20000,...}
If it does have multiple occurrences and you want to get the first occurrence of the result in column H and get the value in column X, best to add a formula right next to your array formula and do a VLOOKUP.
I've scrapped the array formula, as it really slowed down the processing speed. Instead I've created a Unique ID (=IssueID&Date) and VLookup'd that.
I have an Excel 2013 table, called 'student_courses' with columns: stu_id, stu_major, stu_course, and a calculated column named validated_crs.
I am trying to create a formula for the calculated column named validated_crs that evaluates every record.
In this calculated column, I need to reference the value in the stu_major column to find a column in a second table, 'qualified_courses'. The headers in the 'qualified_courses' table correlate with the stu_major values.
I need to check to see if any of the values in the correlated column in 'qualified_courses' match the 'stu_course' value in the record being evaluated in the 'student_courses' table.
If any of the values in the correlated column match the stu_course value for any given record in the first table, then it should return a value of "validated" in the calculated column.
So far, I have found out how to return the second table column values using =INDIRECT("qualified_courses"&"["&[#[stu_major]]&"]"), but I'm not sure how to use the returned set of values to check against the stu_course value to see if there is a match.
Many thanks,
Lindsay
student_courses table:
stu_id stu_major stu_course validated_crs
5432 MULTE BIOL1102 validated
5432 MULTE MUSC1303 NULL
5432 MULTE ENGL2303 validated
6737 MULTM HIST1104 validated
6737 MULTM BIOL1222 NULL
6737 MULTM EDUC2303 validated
6737 MULTM EDUC1302 validated
qualified_courses table:
MULTA MULTB MULTE MULTM
ART1301 HIST1301 BIOL1102 HIST1104
BIOL1322 POLS2210 ENGL2303 EDUC2303
ENGL1440 IS3340 ART3303 EDUC1302
BIOL2302 BIOL1222 MUSC1303
This formula builds on yours:
=IF(ISNUMBER(MATCH([#[stu_course]],INDIRECT("qualified_courses"&"["&[#[stu_major]]&"]"),0)),"Validated","")
We use the MATCH function to search the returned column for the course. If there is one then it returns a number, otherwise an error.
The ISNUMBER returns TRUE/FALSE which the IF uses to determine which outcome.
But I do not like the INDIRECT() Formula as it is a VOLATILE formula. I prefer the INDEX Formula:
=IF(ISNUMBER(MATCH([#[stu_course]],INDEX(qualified_courses,0,MATCH([#[stu_major]],qualified_courses[#Headers],0)),0)),"Validated","")
Which will return the same.
Instead of the INDIRECT to find the correct column we use INDEX/MATCH. Once again the MATCH returns a number, this time of the column in the second table.
The INDEX() uses this nubmer to return the full column at that position. The 0 at the second criterion states that we want the full column.
Then it is just like the first.
VOLATILE formulas are those that recalculate every time Excel recalculates whether the data to which it is tied changed or not.
Non Volatile formulas only recalculate if the data to which they refer changes.
The validated_cs column in the picture is the top formula and the next column is the bottom:
I have the following data set:
I calculate the maximum return using =max(B2:B13) in cell D3 (i.e., 13.55%), and then I would like to find the date where this maximum return was realized. Thus, I use =vlookup(D3;A2:B13;1;FALSE), and I get as a result #N/A, which is clearly wrong. How can I make this work?
You can't use a VLOOKUP to find a value that isn't in the first column of your data table. Use an INDEX/MATCH formula instead:
=INDEX(A2:A13,MATCH(MAX(B2:B13),B2:B13,0))
A VLOOKUP is a Vertical Lookup - and is used to look up a value in the first column of a table and return a corresponding value from another column in that table (just like looking at a timetable for example).
You are trying to find the max value from column B, in column A - where it doesn't exist so you're not going to find it. In order to use a VLOOKUP the lookup_value must be in the first column of the data table.
If you want to look up a value in another column of the data table, then you need to use =INDEX(MATCH()) instead.
I'm trying to use the approximate match function of vlookup to find a value in an array, that can be of different length. I just dragged the lookup array as far down as possible in order to assure that all data is selected, however, the approximate match option will then always select the last value in the array. Is there a way of feeding vlookup the correct lookup array in order to extract the correct value? Regards
Create a dynamic range name and feed that into the Vlookup. For example, if your lookup table starts in A1 and has numeric data, define a name called TheRange with the formula
=Sheet1!$A$1:Index(Sheet1!$D:$D,match(99^99,Sheet1!$A:$A,1))
This will return a range from A1 to column D down to the last row with a number in column A. When rows are added or removed from the table, the named range will be recalculated automatically and adjust to the new dimensions.
Then can use
=vlookup(YourValue,TheRange,2,1)
Adjust cell addresses to your situation. I take it you are aware that for an approximate match the data must be sorted ascending for the formula to return the correct result. With the 1 or TRUE as the last parameter, the formula will always return a result, but if the table is not sorted on the first column, the result is most likely not correct.