Excel - issue with VLOOKUP formula - it doesn't pick dates - excel

I need help with the below formula. I already tried to find a solution for this problem but no success.
If account number exists in column A in the 'Returns' tab and also in column A in the 'July Sales' tab, then I need to get date from the column B in 'Returns' tab.
I manually checked a few accounts on both spreadsheet and find some duplicates.
My formula is as follows:
=VLOOKUP(Returns!A:B,A:B,2,0)
Screenshots:
I tried to change format to text/general, text to columns and trim function but it's still not working.
Also, as I have over 200k rows in each table, can I use any different formula instead to speed this up?
Finally, is there any way to pick dates only if these are within 30 days
Thanks in advance.

You're using Returns!A:B as your lookup value, which doesn't make sense. Instead, try the following:
=VLOOKUP([#Account], tblReturns[[Account]:[Submit_Date]],2,FALSE)
where tblReturns is the name of the table on your Returns worksheet.
I've made the assumption that you're working with tables, since the data in your screenshots is formatted like the default table. If they're just normal ranges, the equivalent is
=VLOOKUP($A2,Returns!$A:$B,2,FALSE)

=IF(COUNTIF(RETURNS!A:A,A2)>0,B2,"NO RETURN INFO")
Not sure what you want done when the account is not found on the RETURNS worksheet. Change "NO RETURN INFO" to what ever text you want including "" for a blank. Make sure you apply the same format for cells in column F as you do in column B. Copy the above formula down as required.

try the below, which will return blanks for non-matches as opposed to errors;
=IFERROR(VLOOKUP($A2,Returns!$A:$B,2,FALSE),"")

I highly recommend an INDEX/MATCH combination over a VLOOKUP. It is MUCH faster, particularly if you are working with a large number of rows. It may even be faster than the COUNTIF solution suggested by #ForwardEd.
=IFERROR(INDEX(Returns!$B:$B,MATCH($A2,Returns!$A:$A,0)),"")

Related

VLOOKUP filling in blank spaces

So honestly I feel really dumb here. I have a very large file that has a lot of blank values where there should have populated a name, and I wanted to use a formula to fill those in. The data that I have is what appears in Columns A and B: A bunch of customer names and corresponding transaction codes (that repeat several times over), but blank spaces in a lot of places where the customer name should be. My attempt to fix this was to try filtering the data to get rid of the blank spaces, and use a VLOOKUP formula off that new table. Any ideas on what I'm doing wrong here? I don't care if it's a VLOOKUP, I just know there's an easier way to fix this that I'm not seeing, but none of the posts I've found fixed my issue...Thanks for any help you can give. Snapshot of Excel Table
Vlookup only performs matching left-to-right: the matching column has to be the first column of the range(D2:D13).
If you have Excel 365, you can use Xlookup:
=XLOOKUP(B7,E$2:E$13,D$2:D$13,,0)
or if not, you can use Index/Match:
=INDEX(D$2:D$13,MATCH(B8,E$2:E$13,0))
It might be more convenient to test for blank cells in column A and fill them in using a separate column if so, eg in C2:
=IF(A2="",XLOOKUP(B2,E$2:E$13,D$2:D$13,,0),A2)

COUNTIF() with filters

I want to count all rows in an Excel table which contain "01.09.2019" in column "D".
First problem: The table is on another sheet
Second problem: Column "D" contains date AND time (e.g. 01.09.2019 00:45:20) but I'm only interested in the dates. I did this with:
=COUNTIF(October_Data!$D$2:$D$299;"<02.09.2019")
This works for me.
But now I want to filter the data and COUNTIF doesn't work with filters.
I found:
=SUMPRODUCT(SUBTOTAL(3;INDIRECT("D"&ROW(2:999)))*(D2:C999<"02.09.2019"))
This obviously doesn't work because the hint to the data-sheet is missing but I really don't know where to use it. Besides of that I tried to rewrite the formula so it fits my needs but I don't really know if I made any mistakes because I have problems understanding the formula.
Here is an image for you:
example table
The data is private so I had to make an example:
Column A is filtered by "a". Now I want to count every row which contains "01.09.2019". In this case it would only be one.
But remember: This table is part of the sheet "October_Data" and my calculations happen in another sheet!
From HERE. With the necessary modifications:
=SUMPRODUCT(SUBTOTAL(3,OFFSET(October_Data!$D$2:$D$299,ROW(October_Data!$D$2:$D$299)-MIN(ROW(October_Data!$D$2:$D$299)),,1))*(October_Data!$D$2:$D$299<DATE(2019,9,2)))
With your local setting you will need to change the , for ;

COUNTIF formula counts values that don't match

I'm using counting invoice numbers (text) in a table's column, but the Excel formula seems to be confusing some values.
I copied small sample of these - please refer to below:
The formulas are as follow:
=COUNTIFS(A1:A19,A1)
=COUNTIF(A1:A19,A1)
As you can see these invoice numbers differ and the results of these functions suggest as if all were the same.
I googled it for 1 hour but I didn't find such as issue as mine.
If anybody had any clue why could this behave in such way I'll be super grateful!
Rob
Each time you copy down this formula it will add 1 row to each. For example the second row of datas formula will be =COUNTIFS(A2:A20,A2). To lock these cells in the formula use $
Your formula should be =COUNTIFS(A$1:A$19,A1)
I've solved this myself:
ROOTCAUSE
Excel tried to be helpful and read these invoice numbers as actual numbers (despite these being defined already in Power Query as text)
Then, Excel fooled me and despite showing that it works on it as a string (I was evaluating the formula) it worked on it as number
Above means that it transformed exemplary "00100001010000018525" to 1.00001E+17, which cut down this to "100001010000018000" - that's the moment Excel stopped fooling around and showed that value in the formula bar.
I think I don't need to tell why countif perceived all these values as equal.
SOLUTION
I simply appended one letter after each invoice number to get e.g. "00100001010000018525a" what forces Excel to quit its gimmicks and games.
Case closed.
I suspect this is a bug in COUNTIF, or maybe by design.
However, to workaround this in the formula, without having to change your data, try adding a wild-card character:
=COUNTIF(A1:A19,"*"&A1)

VLOOKUP is malfunctioning in Excel?

I have been working on this issue for over two hours and I am beginning to question my sanity. I have used vlookup many times in the past, but now it is just not working as expected. I am trying to replicate a LEFT-JOIN (from SQL) in Excel using vlookup.
Here is the formula I am using on cell G2:
Here is the table of all the values I want to lookup values for.
Here is the table I am using as a reference:
I am only searching one column to simplify the example. Cell G2 contains the formula which is applied to the cells under it as well. As you can see from the first image, not only is it not matching but there is some pretty weird behavior going on.
I have removed duplicates for both tables.
I have unformatted the data to plain text values
I have tried this formula on three different computers
Regardless, I keep kept getting the same result! I am starting to lose sanity.
Does anyone have any idea?
Thank you
If you want exact matches, you should be using FALSE as the last parameter
The lookup table must be sorted in ascending order. Cell A369 appears to have a value lower than the row before it, A368. There are several instances of "lower" values occurring after a higher value.
Before you go insane, consider sorting the range $A$368 thru $A$679, and see if that makes a difference.
Otherwise, time to ditch VLOOKUP, and use instead INDEX and MATCH.
Sometimes you can get the #N/A error if your lookup_value isn't "clean". If that's the case, try this formula:
=VLOOKUP(TRIM(CLEAN(A2)),$A$368:$A$697,1,FALSE)
Additionally, your table_array may have "unclean" data, so you'll need to scrub that first before you're able to find a match. To do that, use this array formula, committing it with Ctrl + Shift + Enter:
=VLOOKUP(A2,TRIM(CLEAN($A$368:$A$697)),1,FALSE)
Have you tried doing a MATCH? does it need to be VLOOKUP?
if you are happy using match try:
=IF(MATCH(A2,$A$368:$A$697,0),A2,"NO MATCH")

Using a Variable in Excel for COUNTIF

First time question and I hope it's easier than I'm making this.
Can I use a variable inside a COUNTIF formula?
Currently my formula is:
=COUNTIF($C$2:$C$415,R6)
I would like to have $415 as my variable. I have tried something along the lines of:
D1=415=COUNTIF($C$2:$C$(D1),R6) ..
but obviously get a error.
The reason I need this is column C will constantly be incrementing as I add more rows.
Instead of going into each of my formulas and updated 415 to 416, 417 etc, I would like to just define a Cell that can be my variable, or total rows.
Currently Column C can have blank cells, so I can't have a macro that finds the next empty cell.. but I do however have Column A with a constant populated cell and stops at the last ticket. However Column A is unrelated to the COUNTIF.
UPDATE 1
I'd also like to mention that I'd be using this variable in many formulas in the spreadsheet. Not only COUNTIF's. Also, the COUNTIF contains text.
UPDATE 2
Actually, I figured it out! I am using this formula instead:
=COUNTIF(INDIRECT("C"&D1&":A"&D2),R6)
I'm putting D1=2 and D2=415 and will just update cell D2 with how many rows I have.
I guess I just needed to ask the question thoroughly to fully understand what I wanted!
Thank you in advance for all help, tips and suggestions.
Would "=COUNTIF($C:$C,R6)" do the trick? This will apply COUNTIF to the whole of column C. It's an easy solution, but probably not the most efficient.
I prefer tables for storing data; as new data is added, the table automatically expands and the columns are already labeled (much like Named Ranges). Then you can have =COUNTIF(Table1[Column1],"Criteria"), which will encompass any new rows added to the table automatically. Especially helpful if you have multiple tables in the same column.

Resources