Two Column Lookup - excel

I have a data set that I want to return an indexed column using two values: a year and a name. Both these values are formatted to general (I also tried text) in my spreadsheet.
In one work sheet I have a like of people:
On the other, I have a table of Years, Names, and a number
I am trying to do a lookup on the joined year and name and return the given number in the second table. For instance 2013Andrew McCutchen would return 8.2, and 2014Andrew McCutchen would return 6.8.
Currently, I only get the #N/a value with the following"
=INDEX('2006 Results'!C2:C556,MATCH($J$1&C3,'2006 Results'!$A$2&$B$556,0))
But, I know a certain value is in the table though because I have tested with an if statement to make sure my spelling is correct. Any guidance would be much appreciated.

I would add a column to the left of the year column as column A to contain the following formula in cell A2 which refers to the year and name column:
=$B2&$C2
You can then use this column in a VLOOKUP formula on the people sheet. Cell J3 would read as follows. Copy this to all cells in the table body.
=VLOOKUP(J$1&$C3,'TheYearSheet'!$A$1:$D$556,4,false)
Job done.

In your match expression, you are comparing one concatenated value $J$1&C3 to another single concatenated value '2006 Results'!$A$2&$B$556. Match expects that second parameter to be a range rather than a single value.
In cases like this, where multiple criteria are required, I prefer to use sumifs rather than index-match, even though the intention is to return a single value. I think =SUMIFS('2006 Results'!$C:$C,'2006 Results'!$A:$A,j$1,'2006 Results'!$B:$B,$c3) will give what you need and should correctly copy to the other cells in that table.

Related

Excel - looking for coincidence of two different values in two different columns and extract another column

I am trying to extract the value like what we can do with vlookup, but in this case it has to coincide with the value on two different columns.
I want to extract the values which match with the two columns in yellow.
Sheet1 (where I am looking for coincidence of two values)
For that I am using the formula IF(COUNTIFS(....)=1;"value that I am looking for"; no match)
But I donĀ“t know what to put on "value that I am looking for", because if I add directly the cell from the row, it delivers directly a wrong value.
Sheet2 (where I want to add these two values, and formula that I am testing)
If you have O365, you can use a combination of INDEX and FILTER function to do this
=INDEX(FILTER('Sheet 1'!$A$2:$E$10,('Sheet 1'!$A$2:$A$10='Sheet 2'!$B192)*('Sheet 1'!$E$2:$E$10='Sheet 2'!$C192),""),1,2)
You need to update the 'Sheet 1'!$A$2:$E$10 range according to your data.
Also note that this will return the 1st match of both Partner object and Value in Obj. Crcy row, even if there are multiple matches
Edit:
As suggested by #P.b in the comments below, you can also use:
=#FILTER('Sheet 1'!$B$2:$B$10,('Sheet 1'!$A$2:$A$10='Sheet 2'!$B192)*('Sheet 1'!$E$2:$E$10='Sheet 2'!$C192),"")

Two formulas I'm having issues with

this is my first time asking a question here, but I have two formulas that I'm not really sure why they aren't working.
The first issue I'm having is with this formula:
=MAX(IF(C46:C51<80,B46:B51))
Any reason that this formula returns #VALUE! I'm supposed to find the max value of data in column B so long as the data in column C is less than 80.
Then I'm having issues with VLOOKUP on two questions, that are related I have a large dataset on a separate worksheet. I need to VLOOKUP someone's name to find a value associated with that name. The problem is that their name comes up multiple times. The formula I have for it so far is:
=VLOOKUP('PDR DATA'!E80,'PDR DATA'!A4:V119,15,FALSE)
Where 'PDR DATA'!E80 is the first instance of the person's name appearing. However, using FALSE with VLOOKUP returns #N/A, but if I use TRUE it returns the very last value from column 15 even though the name is different from what I'm searching for. I'm lost here and don't know where to turn.
=MAX(IF(C46:C51<80,B46:B51,C46:C51)) works for me. (Please ensure B46:B51 & C46:C51 has integer values)
=VLOOKUP(cell you want to lookup for, cells where you want to lookup(maybe more than one column), which column you want to fetch from (number), rangelookup) try to understand the syntax and give your inputs
ex: If I have a existing data with Name and id in sheet2, need that id in sheet1 by using the name then I will use =VLOOKUP(L2,Sheet2!A2:B5,2,TRUE)
L2 is the sheet1 name, then I have selected both columns(A,B) and rows in sheet2, then column number is 2.

Using tables and column titles in VLOOKUP

I'm having a very difficult time with transitioning my VLOOKUP statement from simply referencing sheets and ranges (which work like a charm), to instead using table and column names.
I'm trying to make the VLOOKUP a bit more robust as the sheet where it is pulling from will constantly be changing data, so column numbers will change frequently. Thus, I'd like to just reference a column by its name.
I have converted the source data sheet to a table.
I have named all columns appropriately and double checked spelling.
This VLOOKUP works great (currently):
=VLOOKUP(E6,'Costs'!$A$2:$AE$84,19,FALSE)
However, what I would like to do is make it look this:
=VLOOKUP(E6,tblCosts[Order Number],tblCosts[June 2017], FALSE)
I have been fiddling with also trying to use MATCH which is not working either:
=VLOOKUP(E31,tblCosts[Order Number],MATCH(F4,tblCosts[June 2017],FALSE),FALSE)
UPDATE
This formula now works but it is returning the order number...not the cost for the month.
=VLOOKUP(E31,(tblCosts[Order Number]),(tblCosts[June 2017]),FALSE)
Normally I would keep trying this myself...but I am feeling overwhelmed and have been trying for hours. Any advice would be great.
Thank you!!
This should work for you:
=VLOOKUP(E31,tblCosts[#All],COLUMN(tblCosts[Jun-17]),false)
The COLUMN(TblCosts[Jun-17]) returns the column number of the field you want.
The VLookup searches the first column of tblCosts[#All] - (all the data in the table) for the data (in E31) and returns the data in the column you want.
This formula will continue to work even if you add columns or rows to the data.
Make sure that any heading which looks like a date in your spreadsheet eg "Jun-17" is stored as Text and not as a Date, as it will not match the string "Jun-17" when you use VLookup.
=VLOOKUP(E37,tblCosts[#All],match("Jun-17", tblCosts[#Headers]),FALSE)
This match is looking for the column name in all column headers and will return the number of columns to the right of the first column rather than the column number in the sheet. This avoids having to use COLUMN(tblCosts[Jun-17]) - COLUMN(tblCosts[Order Number]) + 1 when your table doesn't start in column A.
Ref: https://www.excel-university.com/vlookup-hack-4-column-labels/

Excel - Conditional row from an array to COUNTIF from VLOOKUP

I don't know if I'm going about this the wrong way but it seems like it should be simple. Column A has a list of Names. Along each row is several "W"'s. Another separate field has a drop down representing Column A names. I want to count the number of "W"'s in a row corresponding to what name I select. I've tried using VLOOKUP and COUNTIF but I can't figure out how to select the entire array and then single out the one row that matches my selected name. I can get it working with a bunch of IF statements but thats far too time consuming as I'm manually matching the name to the row (and it isn't future proof).
There are a few ways to first 'narrow in' on the row you're looking for, after which point you can use a simple COUNTIFS to check the number of W's in that row.
One method would be to simply use INDIRECT, and create the row reference on the fly, like so [assumes your search cell is C1]:
=COUNTIFS(INDIRECT(MATCH(C1,A:A,0)&":"&MATCH(C1,A:A,0)),"W")
This first uses MATCH to find the appropriate row, and then builds a reference to that row [like "24:24"], which becomes the row that INDIRECT passes to COUNTIFS, which counts that row for W's.
For only one use of INDIRECT, the high computing costs of INDIRECT should not be an issue.
Another method would be to point out the full possible box that data could be contained in [let's assume that at most only column H would be used], and then use INDEX to give us the appropriate row number, like so:
=COUNTIFS(INDEX(A:H,MATCH(C1,A:A,0)),0,"W")
This again uses MATCH to find the row which contains the value found in C1 within column A. Then it takes the full possible box from INDEX, and returns all columns from the particular row [note that telling index to return 0 for the column # actually returns all columns instead].
Other methods would be possible [for example OFFSET], but I believe these two show the principle fairly well.
You could use the "Helper" Column method:
In the helper column:
=COUNTIF(B2:H2,"W")
Then use SUMIF() in the totals column:
=SUMIF($A$2:$A$9,K2,$I$2:$I$9)

DGET NUM error with criteria

DGET functions in my spreadsheet have a problem with criteria strings having the same starting characters. This is a problem. How do I resolve this?
Ex: =DGET(database, field, criterion1)
The database contains entries for criteria values of "ABC" and "ABC_123", say.
If I call DGET(database, field, "ABC"), it results in a NUM error. What do I do about this? I cannot change the spreadsheet from which the criteria values are extracted for input into the DGET function - for example I can't add columns, etc. I may be able to make some limited changes to the database entries.
I think you will need two changes (though due to #NUM error instead of #VALUE maybe just the first). To do an exact match with DGET you need to preface your criteria with =. So instead of "ABC" you would need "=ABC". The final parameter of the DGET function does not want a single string value. As noted on the MSDN page:
You can use any range for the criteria argument, as long as it includes at least one column label and at least one cell below the column label in which you specify a condition for the column.
I think that third parameter should be a range of two cells with your criteria field name in the first cell and your criteria value =ABC below it. You can place this range on another worksheet if you like to stage it with the = as you pull it in from the other spreadsheet.
For example in my testing I am using the formula =DGET($G$1:$I$4,"Field 3",A1:A2) where A1 is Field 2 and A2 is ="=ABC" and columns headers are in G1:I1. This returns the value in column Field 3 when column Field 2 is ABC exactly.
DGET is touchy and not something I usually recommend so make extra sure you run key test cases when making revisions and verify this returns exactly what you want.

Resources