VLOOKUP is not matching properly - excel

I have a multisheet excel file where I am in sheet3 and trying to find the data for a person in sheet2 but it doesn't match correctly, it gets the data of another person.
So I am trying to get the number of days for "Tim" from sheet2:
but is shows like that:
The code is I used was =VLOOKUP($B81,sheet2!$A$2:$M$281,2)

try
=VLOOKUP($B81,sheet2!$A$2:$M$281,2,FALSE)
or
=VLOOKUP($B81,sheet2!$A$2:$M$281,2,0)
if you want exact match.
The last argument of the VLOOKUP function determines the nature of your look up.
1 - TRUE will return an approximate match which is useful when you want to look up a value from group of ranges in ascending order;
0 - FALSE will return an exact match which will return the first match based on your look up criteria.
If you do not input the last argument in your formula, Excel will presume you want to use 1 - TRUE and do an approximate match which will look up the closest (and smaller) match of Tim such as Sam which is considered ahead of Tim and return the value corresponding to Sam instead. However, if your formula is =VLOOKUP($B81,sheet2!$A$2:$M$281,2,) with a comma , at the end of 2, Excel will presume you want to use 0 - FALSE and do an exact match.

Terry W already answered about the exact match, however here you go for some more trail which helps you to work with v-look up easier way.
Table Of RAW Data
Table Of Sheet 2, where we need values of TIM
Trail 1 (Used For Jan):
=VLOOKUP(B4,Raw!A1:M4,2)
Which is worked without using exact match function, as you tired.
Trail 2 (Used For Jan):
VLOOKUP(A4,Raw!A1:M4,2,0)
Which is worked using exact match function as "0", as you tired.
Trail 3 (Used For Jan):
=VLOOKUP($B10,Raw!$A$1:$M$4,MATCH(C$9,Raw!$A$1:$M$1,0),0)
Here instead of using the Index_Num Used match function and used Exact Match Argument too. The match function helps to get exact value of the month, and which make work easier instead of mentioning the Index_Num as 1 and 2 and 3 and Ext... for next and next months. Below snap is for your view.
Please let me know if need any more clarification need on this.

Related

Excel VLOOKUP returns #N/A when allowing approximate match, but returns value when requiring exact match?

Run across a very strange issue that I am curious about. In Excel, I was doing a VLOOKUP to match contact names with a unique ID found in another database. Formula for example: =VLOOKUP(B2,Sheet2!A:B,2,TRUE), very basic. I used approx. match but, of course, some instances still returned #N/A. However, I did double checks with a quick control-F and found a number of instances returning NA when there was in fact a (exact) match. I was troubleshooting and trying a number of things but nothing was working. Many checks confirmed the cells were equal, there was nothing tricky like hidden characters, very peculiar. Anyway, on a whim I changed from approximate match to exact match and lo and behold it worked! The VLOOKUP was returning the correct value.
I'm trying to understand why this is. Obviously if you were requiring an exact match but there was only an approx. match it would return NA. But it doesn't make sense the other way around. An exact match should be returned when allowing even approx. matches! So just trying to understand what is going on behind the scene in VLOOKUP/Excel to make this phenomenon occur.
Appreciate any insight!
When working with approximate VLOOKUP, the key-column (always the 1st column of matrix-range) in the lookup-matrix should always be sorted in ascending order. The reasons for this is the following:
Imagine a key column with the values [2,3,10,4] in the given order. When the key '4' should be looked-up approximately, the function will start comparing the available keys in the column, beginning with '2'. After '3' was passed, '10' follows, which is already greater than the searched '4'. Consequently, the function stops searching and returns the target value of the previous key-row ('3') as an "approximation".
Now, given another example [10,2,3,4]. Here, approx. VLOOKUP will stop searching right after the first key comparison as '10' is greater than the searched '4'. Since no previous key-row is available, the returned value will be #N/A. However, an exact VLOOKUP would have found the matching key as it does not stop searching.
Besides key order, it is recommended to have all the key-values in the same format.
Hope this helps.

MATCH function not working on Table headers for some reason

I am getting n N/A error when I am searching for a specific day in the header row. If you look to the right you can see the formula where I have searched for the position of 5 using MATCH and it works.
I have tried the following variations as well
MATCH(F7,Table2[[#Headers],[1]:[60]],-1)
MATCH(F7,Table2[[#Headers],[1]:[60]],1)
But these do not work.
On the right you can see that I have created a simple range of numbers from 1 to 9 and I have searched for the number 5 in it, it is working.
PS: I know I can just use the number "23" without using MATCH. But that is not the point, the column orders may be jumbled in some cases (product ID for example). The MATCH function shouldn't fail there.
Being used as table-headers the days are not treated as numbers. Thus, you need to convert the expression you would like to match into text using TEXT() like this
=MATCH(TEXT(F7;"0"); Table2[#Headers]; 0)
Hope this helps.
I would try =index(area or table, 1 this is the row, match( field to match, area to search, 0 = exact match))
Example source here https://exceljet.net/lessons/how-to-use-index-and-match-with-a-table
Hope this helps.

Indexing an answer limited to after today in Excel

I'm trying to put together a company excel sheet to keep track of the tickets we give out to senior sales to take out clients.
I put together a "Soonest Available Ticket" section to easily ID what games are coming up we still have tickets for. However, we don't give out tickets to every game and so I want to have these formulas return dates only of games that have not happened yet. Right now, they simply return the first unclaimed game which are all in the past.
I've tinkered with a few formulas, but I can't figure out how to only command it to look at dates today or later. Any ideas?
Below, in order, are my original Index formula, and then my attempts to only find upcoming games.
=IFERROR(INDEX(CubsDate,MATCH("Avail*",CubsTicketStatus,0),1),"Filled")
=IF(WhiteSoxDate>NOW(),IFERROR(INDEX(WhiteSoxDate,MATCH("Avail*",WhiteSoxTicketStatus,0),1),"Filled"),"Season Ended")
=IF(WhiteSoxDate>NOW(),INDEX(WhiteSoxDate,MATCH("Avail*",WhiteSoxTicketStatus,0),1),"Season Ended")
{=INDEX(WhiteSoxDate,(MATCH("Av*"&"*">TODAY(),WhiteSoxTicketStatus&WhiteSoxDate,0)))}
Assuming that "CubsDate" and "CubsTicketStatus" are named ranges of cells (the former containing dates and the latter the status, either "Avail" or "Filled"), then perhaps this will do what you want:
{=INDEX(CubsDate,MATCH(1,(CubsTicketStatus="Avail")*(CubsDate>TODAY()),0))}
Note that if there is no matching date after the current date, you'll get an #N/A result (which you could easily test for).
Here's a test I ran:
Note that the data here is in rows 25 - 31. Also, you'll need to format the result as a date.
Hope this helps!
Edit: Here's an explanation of how the Match function is being used. (I edited the answer so that future generations will find it more easily than if I added a comment.)
As a reminder (because I'm old and forgetful), the Match function takes three parms: Lookup Value, Lookup Array, and Match Type. So in
MATCH(1,(CubsTicketStatus="Avail")*(CubsDate>TODAY()),0)
we're looking for a value of 1 with a match type of 0 (exact match). That's the easy part. Our Lookup Array, however, is a little more complex. It consists of two tests multiplied by each other. So in each row, it looks at the value in CubsTicketStatus to see if it is "Avail" and it looks at the value in CubsDate to see if it's after today.
Each of those tests results in either TRUE or FALSE but, when you put them in the context of a mathematical calculation, they are 1 and 0. So if they're both TRUE, then you get 1 * 1, but if either (or both) is FALSE, you get zero. The Match function then returns the first row where both are TRUE -- that is, the first row where tickets are "Avail" and the date is after TODAY().

Excel formula to search partial match and align row

I have 2 column data in Excel like this:
Can somebody help me write a formula in column C that will take the first name or the last name from column A and match it with column B and paste the values in column C. The following picture will give you the exact idea what I am trying to do. Thanks
Since your data is not "regular", you can try this formula which uses wild card to look for just the last name.
=INDEX($B$1:$B$4,MATCH("*" &MID(A1,FIND(" ",A1)+1,99)&"*",$B$1:$B$4,0))
It would be simpler if the first part followed some rule, but some have the first initial of the first name at the beginning; and others at the end.
Edit: (explanation added)
The FIND returns the character number of the first space
Add 1 to that to get the character number of the next word
Use MID to extract that word
Use that word in MATCH (with wild-cards before and after), to find it in the array of email addresses. This will return it's position in the array (row number)
Use that row number as an argument to the INDEX function to return the actual email address.
If you want to first examine the email address, you will need to determine which of the letters comprise the last name. Since this is not regular according to your example, you will need to check both options.
You will not be able to look for the first name from the email, as it is not present.
If you can guarantee that the first part will be follow the rule of one or the other, eg: either
FirstInitialLastName or
LastNameFirstInitial
Then you can try this:
=IFERROR(INDEX($B$1:$B$4,MATCH(MID(A1,FIND(" ",A1)+1,99)& LEFT(A1,1) &"*",$B$1:$B$4,0)),
INDEX($B$1:$B$4,MATCH( LEFT(A1,1)&MID(A1,FIND(" ",A1)+1,99) &"*",$B$1:$B$4,0)))
This seems to do what you want.
=IFERROR(VLOOKUP(LOWER(MID(A1,(SEARCH(" ",A1)+1),LEN(A1)))&LOWER(MID(A1,1,1))&"*",$B$1:$B$4,1,FALSE),VLOOKUP(LOWER(MID(A1,1,1))&LOWER(MID(A1,(SEARCH(" ",A1)+1),LEN(A1)))&"*",$B$1:$B$4,1,FALSE))
Its pretty crazy long and would likely be easier to digest and debug broken up into columns instead of one huge formula.
It basically makes FLast and FirstL out of the name field by splitting on the space.
LastF:
=LOWER(MID(A1,(SEARCH(" ",A1)+1),LEN(A1)))&LOWER(MID(A1,1,1))
And FirstL:
=LOWER(MID(A1,1,1))&LOWER(MID(A1,(SEARCH(" ",A1)+1),LEN(A1)))
We then make 2 vlookups for these by using wildcards:
LastF:
=VLOOKUP([lastfirst equation from above]&"*",$B$1:$B$4,1,FALSE)
And FirstL:
=VLOOKUP([firstlast equation from above]&"*",$B$1:$B$4,1,FALSE)
And then wrap those in IfError so they both get tried:
=IfError([firstLast vlookup],[lastfirst vlookup])
The rub is that's going to be hell to edit if you ever need to, which is why I suggest doing each piece in another column then referencing the previous one.
You also need to be aware that this answer will get tripped up by essentially the same name - e.g. Sam Smith and Sasha Smith would both match whatever the first entry for ssmith was. Any solution here will likely have the same pitfall.

Exact case matching with excel vlookups

I have a spreadsheet which contains 'unique' IDs. The problem is that they are only case sensitive unique, meaning that I have: a06D000000QO5uW & a06D000000QO5uw.
I want to perform a vlookup on these IDs and pull back a related value. It's possible to do case sensitive matching using this article I found:
http://support.microsoft.com/kb/214264
The problem I have found is that because the vlookup is nested within the Exact function, it returns the first match it finds, which may not be the one I am after. If I use the data sample from the article, it looks like:
Name Age Joe
Mary 32
joe 48
Bob 53
Sue 27
Joe 30
and the look up looks like:
=IF(EXACT(C1,VLOOKUP(C1,A1:B6,1,FALSE))=TRUE,VLOOKUP(C1,A1:B6,2,FALSE),"No exact match")
The problem seems to be that the vlookup to test "Joe" comes across "joe" first of all and because it isn't case sensitive returns that as a match - meaning it never gets to "Joe". The exact function then fails because it is trying to test "Joe" against "joe".
Is there any way around this? I really wanted to avoid going down the VBA route because we have a mix of Mac and Window users and so I wanted to keep it to formulas.
Your problem (with this exact example) is covered here
The array formula (press Ctrl ShiftEnter
) together will return 30 against joe (NA if no match is found). =INDEX(B1:B6,MATCH(1,--EXACT(A1:A6,C1),0))
A more straightforward formula mentioned in the same article is =LOOKUP(1,1/EXACT(A1:A6,C1),B1:B6)
I think that there is a slightly better way as it does not use an array formula.
=INDEX($B$2:$B$6,MATCH(TRUE,INDEX(EXACT(C1,$A$2:$A$6),0),0))

Resources