Get first non-empty cell that matches a value in VLOOKUP - excel

I have an Excel sheet with 2 columns: Invoice Number and Invoice Amount.
[
The first column (Invoice Number) has many duplicates, and the second column (Invoice Amount) has only empty cells except there is one amount that matches the sum of the invoices.
I have already consolidated all of the unique Invoice Number values into another sheet and now I am trying to add all of their corresponding Invoice Amounts to that sheet as well.
I have tried many VLOOKUP, MATCH, INDEX, IFERROR functions and cannot get this to work.
Whatever function I try, fails because it only returns the empty cell that matches.
For instance, in the image I would want to do a VLOOKUP or related function that can return '2462.87' for every row with the Invoice Number '1891936'.

Sort your data by columns B, C.
Do a VLOOKUP
The first line with a new Invoice Number also holds the invoice_amount, therefore the VLOOKUP returns what you need.

What's wrong with this approach: instead of looking for that one cell which contains the value you're looking for, just sum everything together: if a cell is not filled in, the value is zero and it does not impact the sum anyway.
As a result, you get something like in the following sheet:
The used formula is =SUMIF(A$2:A$16,D2,B$2:B$16).

Related

How to search for a particular row, column value and then return the row number?

I'm having an trouble making an excel formula at the moment which would get first search for the row, column value and then return the row number from which I can get the another column value in the same row.
Right now, I've made this function. =INDEX('Rent'!$D$2:$D$73, MATCH(0, ($B$6='Rent'!$B$2:$B$73)*($C$7='Rent'!$A$2:$A$73),0))
Here rent is another sheet, and first i'm searching for the particular value like $B$6 here in first MATCH function by searching for the value in 'Rent' sheet's column and then same for next check. The resulting match would contain bow $B$6 and similarly $C$7 in the same row and then I want to return the value of another column value in the same row.
Please, let me know how can I do this. I've been stuck at this a long time.
The rent sheet looks like this:
Based on your data, I think you can just use SUMIFS for this:
=SUMIFS('Rent'!$D$2:$D$73,'Rent'!$B$2:$B$73,$B$6,'Rent'!$A$2:$A$73,$C$7)

Find Last Entry in Row, then Return Value of Cell in Top Row of That Column

I have a spreadsheet that records how many times different people have been to an event, names vertically, dates horizontally, with a 1 in each cell to denote attendance, so that the total can be summed up.
What I want is to automate the process of working out who hasn't attended in a long time, so that it will lookup the right-most (most recent) entry in a row, and return the value of the date, which will be in row 1 of that column, so I can create a column of last attended date to sort data by.
I can't work out how to assemble the formula for this, what would be the best way to do it?
Many thanks for any ideas!
You could use an array formula:
{=MAX((B2:D2)*$B$1:$D$1)}
This formula would be the one to use for the 2nd row, assuming that the 1st row contains your dates and that dates range from column B-D.
Using the array formula carries out a vector multiplication (item by item) so in case there is a 1 (marking attendance) the date will be considered in the MAX formula an in case the cell is empty it will be effectively a zero. Therefore the MAX is only applied to dates where there is an attendance and the result will be the latest attendance date.
For an array formula to work you will need to use Ctrl+Shift+Enter after entering it into the cell. The brackets {} will then be added automatically. You do not type these yourself.

VLOOKUP value not available to formula or function but it should be

I am using the following formula:
=VLOOKUP(E9, 'Raw data'!$A$1:$I$45857, 9, FALSE)
I have two tabs and I want one column in my first sheet to lookup the # value found in 'raw data' associated with the ID number found in column E (data begins on cell E9). my second tab, 'raw data', includes that same field as found starting on E9 in sheet 1 within the data range A1:I45857. The column I want returned from 'raw data' is the 9th column. I want to be exact matches only.
What I think excel is thinking - look for e9 in the array 'raw data' and when I see it, return the value that I find in the 9th column of that row within array 'raw data'.
What excel is saying - A value is not available to the formula or function
I am confused because the value is in fact available within that array. when I filter and search for just one of the IDs, I find it in both sheets. The data type is number for both columns and there are no rogue spaces or anything...
My goal is ultimately to take a subset of ids and look at the difference between the # found on sheet1 and the number found on 'raw data'. I am Vlookup-ing so that i can grab the # value on 'raw data, set it right next to the # i am comparing it to on sheet1 and then I can pivot the data to aggregate both of those numbers based on ID and create a calculated field showing the % difference between the two.
Any input on how to fix my vlookup or a workaround to join my # from 'raw data' to sheet1 based on a common ID is MUCH appreciated.
I recommend that you look into the combination of INDEX & MATCH, rather than VLOOKUP, for situations like this. VLOOKUP has 2 main flaws: (1) you have to order your data so that your search term is the left-most column of a continuous data block [as you have just seen]; and (2) it is volatile, meaning that when a column is inserted within your data block, it will no longer properly 'count' the number of columns to move to retrieve your data.
MATCH is like half of VLOOKUP. You give MATCH a specific column or row, and a value to search for, and it will simply return the number of cells in it had to move to find that value.
=MATCH(A1,B:B,0)
This says 'look at B:B, and tell me what row the value of A1 appears on'.
INDEX is like the other half of VLOOKUP. You give INDEX a group of cells (either a row, column, or a 2D range), and a specific row number (plus potentially a column number), and it will return the value for that cell.
=INDEX(C:C,5)
This gives you the value of cell C5, which is the 5th row found in the column given to INDEX. Combine these two formulas and it will return the value of column C, where column B matches A1:
=INDEX(C:C,MATCH(A1,B:B,0))
This formula gives an identical result to
=VLOOKUP(A1,B:C,0)
VLOOKUP looks simpler here, but INDEX & MATCH is much more versatile - in your case, you wouldn't have needed to reorder your data to get it to work, you could have used the formula:
=INDEX('Raw Data'!I:I,MATCH(E9,'Raw Data'!E:E,0))
Once you get into the habit of using INDEX / MATCH over vlookup, you will find that your data is a lot more flexible to manage.
Got it to work by making my ID field in 'raw data' the leftmost column.
You don't need to start the Vlookup in column A. If the ID column is not in column A, Vlookup can still work, as long as the ID column is to the left of the column you want to return. So, if you want to return the value from column I, and the ID column is in column F, you can leave the table as it is and change the Vlookup to
=VLOOKUP(E9, 'Raw data'!$F$1:$I$45857, 4, FALSE)
This will look for the match in column F and returns the value from the fourth column, which is column I.

Filter data in one column based on data in other column

How can I find duplicate records using their Item Number and copy/extract Unit Price?
You can use a vlookup to find when an item matches another item in a different column. For your example, assuming that row 20 column F contains the item 52F233, use this formula for cell I20
=VLOOKUP(F20,$G$1:$H$1000,2,FALSE)
This will put the unit price in cell I20 when a match is found and #N/A otherwise. You can paste this formula in the entire I column and it will show you when the match is found for each entry. After that, you can sort the ones with a valid match and take the next action you need with the matched data, such as add to a different sheet. The vlookup formula cna be used across multiple files.

Conditional VLOOKUP

I have two excel spreadsheets:
One has an id and a date
The other one has an id, two dates and a value
I am supposed to match the ids and return the value whenever the date in spreadsheet 1 is between the two dates in spreadsheet 2.
There is a one-to-one correspondance between those spreadsheets, and a default value of 0 if no match is found
The first spreasheet has a lot of lines. Would there be some sort of VLOOKUP function that I can use to get the right data?
SUMPRODUCT and array formula's are what you need.
=SUMPRODUCT(--(Sheet2!$A$2:$A$2000=A2),--(Sheet2!$B$2:$B$2000<B2),--(Sheet2!$C$2:$C$2000>B2),--(Sheet2!$D$2:$D$2000))
this will have to be entered as an array formula with CTRL+SHIFT+Enter. you will see excel surrond the formula with {} if you have entered it correctly.
Assumptions: ID to be checked in A2, Date to be checked in B2
Data on sheet 2 in the order A ID, B start date, C end date, and D value (numeric)
the array formula returns a list of true/false, which is then multiplied together. only if all criteria are True is a value returned (as any False answers equate to zero, and zero * another number is zero).
This will give incorrect answers if 2 ranges overlap
There was a very simple way to achieve that: concatenate the multiple fields you want to search, and you are done, provided they are unique. Otherwise you should look into array cells.

Resources