I have a matrix dataset with values in Excel, where row and column names are identical. I have put all matrix values in a single column, but would now like a formula that returns the matching row name and/ or column name for that value. I have tried VLOOKUP and versions of INDEX and MATCH, but can't get it to work.
Here's an illustration of the data:
Setup:
Source table range A1:D4
Values populated in column H for checking.
Formula in cell F2:
=IFERROR(INDEX($A$1:$A$4,MIN(IF($B$2:$D$4=H2,ROW($B$2:$D$4),10^10))),"")
Formula in cell G2:
=IFERROR(INDEX($A$1:$D$1,1,MIN(IF($B$2:$D$4=H2,COLUMN($B$2:$D$4),10^10))),"")
Depending on your version, you may have to use CTRL+SHIFT+ENTER to implement these formulas. Output will be like below.
You are not looking for a rowname or a columnname, you are looking for the content of the first row or column:
Imagine you want to know the "columnname" of cell "C4", then you just ask for Cell(3,1) (3 meaning "C").
Imagine you want to know the "rowname" of cell "C4", then you just ask for Cell(1,4).
Related
I have the above formatted table.
I want to merge all last values in every row under a single column "Last Cell".
Could somebody please help.
Thanks in advance.
Please try this formula in your table's last column.
=IF(MOD(COUNTA(Table1[#[IN]:[OUT4]]),2),"",INDEX(Table1[#[IN]:[OUT4]],1,COUNTA(Table1[#[IN]:[OUT4]])))
The term Table1[#[IN]:[OUT4]] appears 3 times. It specifies the range from the IN column to OUT4 column in Table1. Change the table name to match the name of your table. You can also specify a sheet range, like A2:H2.
The formula returns nothing (blank) if the last used column is an IN column and the value in that column if it's an OUT column. The column is identified by the MOD() function. MOD(COUNTA(Table1[#[IN]:[OUT4]]),2) will either return 1 or 0. IF(MOD(COUNTA(Table1[#[IN]:[OUT4]]),2),"", will return a blank if the result is 1. If you have columns to the left of what you showed us, and need to include them in the range examined by the formula, you may have to change this part of the formula into IF(MOD(COUNTA(Table1[#[IN]:[OUT4]]),2)=0,"", to omit results if the last column is an IN column.
What you are looking to do is CONCATENATE which means to merge the data together.
You can use
=CONCATENATE(cell1, " ", cell2)
-- OR --
The less 'codey' way of doing this is to merge the data without using the =CONCATENATE() formula: =A1&" "&A2&" "&A3&" "... etc
I have an excel spreadsheet where it has duplicate column header titles labeled "'H ". I'm attempting to calculate the sum of a row if it is under this certain header value. I tried pivot tables but it hasn't worked too well.. I feel as though I'm not using the sumif properly.
Please help this excel beginner!
This is what I used so far:
=SUMIF(B$2:$M5, B$2:$M5="'Q ", B6:M6)
above is what my data would look like, below is the summary that I would want
Based on your image, and assuming it starts on A1, use this code in Cell B5 and copy it to the right.
=SUMIF($B$1:$G$1,B$4,$B$2:$G$2)
so the SUMIF function requires three values:
the range which you are searching.
the criteria (value) you are searching for.
the range which you want to return for your sum.
so in your case, I think it might look like this if you are searching column headers to find values in the columns/rows below them:
=SUMIF($A$2:$A$10,$A$1,B2:B10)
This would return the sum of all cells in row B that are under column headers shown in the range A2:A10 with the value shown in A1 (you can change the value in A1 to "H", "Q", or whatever you like). You could copy this formula down for all of the rest of your rows if you have multiple rows to find values for.
Hopefully this helps.
JW
I'm trying to create a formula in column K which sums all cells that apply , in column J, only when the following conditions are true:
dates are the same in column A
AND client name is the same in column B
For example, in cell K2, I want the sum of J2+J3+J4 because A2=A3=A4 and B2=B3=B4.
K5=J5 only, because there are no other dates with the same client name.
K6=J6+J7 because A6=A7 and B6=B7.
What kind of formula would I use for this? I can't figure out how to do it with a SUMIFS.
I would try using a pivot table with:
The names as row values
The dates as the column values
And funds received using SUM in the values column
Edit
Based on #pnuts comments here is how to get the values in column K. Put this in K2 and drag down.
=IF(OR(COUNTIFS($B$1:B3, B3) = 1, B3 = ""), SUMIFS($J$2:J2, $A$2:A2, A2, $B$2:B2, B2), "")
This formula will give blank values until the formula finds a new client on a new date. However, I still think using pivot table is a better solution.
However, I still find the pivot table
In cell K2 put following formula:
=IF(COUNTIFS($A$2:A2,A2,$B$2:B2,B2)=1,SUMIFS($J$2:$J$10,$A$2:$A$10,A2,$B$2:$B$10,B2),"")
Adjust row 10 value. It will be last row of your actual data.
Copy down as much you need.
EDIT
Uploaded file shows the cause behind formula not working correctly for you. It turned out to be whitespace characters in column B (names) data e.g.
Cell B3: "Moe John" has a trailing space.
Cell B10: Same case with "Doe Jane"
If you want to use above posted formula then all names shall be corrected. Or alternatively to deal with spaces you can adopt below approach.
=IF(COUNTIFS($A$2:A2,A2,$B$2:B2,"*"&TRIM(B2)&"*")=1,SUMIFS($J$2:$J$28,$A$2:$A$28,A2,$B$2:$B$28,B2),"")
Notice the change in COUNTIFS formula where B2 is now replaced with "*"&TRIM(B2)&"*".
Even such formula will take a beating if you have uneven whitespace characters in between your data. I'd suggest normalizing it as much as possible.
So this seems like it should be pretty easy. I could just concatenate and make another column in the data to make a unique combo and get my answer. But that just seems so messy. So here I am reaching out to you fine folks to pick your brains.
I want to look up HQLine and Description in the MPCC tab to return the correct MPCC Code. I tried a couple IF statements with VLOOKUPS but couldn't get it right.
So I need to look up BK3 Positive Crankcase Ventilation (PCV) Connector in the MPCC tab. So it needs to match BK3 and the Long description and then give me the correct code.
Here is the missing data file
Here is the MPCC export list that I want to search
Use SUMIFS.
SUMIFS will find the sum in a table of rows that meet certain criteria. If the MPCC is always a number, and the MQAb-LongDescription is always unique, SUMIFS will find the correct ID.
=SUMIFS(Sheet1!C$2:C$100,Sheet1!A$2:A$100,A2,Sheet1!B$2:B$100,B2)
where Sheet1!A$2:A$100 is the HQAb data, Sheet1!B$2:B$100 is the Long Description data, Sheet1!C$2:C$100 is the MPCC Number data, A2 is the HQLine, and B2 is the Description.
The formula would go in C1.
More information on VLookup with Multiple Criteria
You can use an Index/Match with multiple criteria.
I'm assuming that you will put this formula in "Sheet1", cell C2, and your lookup data is in a sheet called "Sheet2", columns A, B, C from row 2 to 30.
Put this in Sheet1, C2:
=INDEX(Sheet2!$C$2:$C$30,MATCH(A2&B2,Sheet2!$A$2:$A$30&Sheet2!$B$2:$B$30,0))
(Enter with CTRL+SHIFT+ENTER) and drag down.)
Adjust the ranges as necessary.
lets assume your first Table is on sheet 1 in the range A1:C11 and the MPCC codes are located on Sheet 2 in the range A1:C32. Each table has a header row so your data really starts in row 2.
Similar to BruceWayne's answer of using an array formula, you can bring the array calculation inside of a formula and avoid the special array treatment. There are a few functions that can do this. I will demonstrate with the SUMPRODUCT function;
On Sheet 1, Cell C2, use the following formula:
=INDEX('Sheet 2'!$C$1:C$32,SUMPRODUCT((A2='Sheet 2'!$A$2:A$32)*(B2='Sheet 2'!$B$2:B$32)*row('Sheet 2'!$A$2:A$32))
Explanation:
When the value in A2 matches the value in the range in the second sheet it will be true and false when it does not. when True False get used in math operations they are treated at 1 and 0 respectively. Therefore the only result from your two search criteria will be the rows where A2 match is true and B2 match is true and this will have a value of 1. The 1 will then be multiplied by the row number. Since all other results will be 0 since your list is a unique combination, the sum part of sumproduct will sum up to the row number where your unique row is located. This in turn is used by the indext function to return the row to give your unique number.
I am referring to below my google spreadsheet
https://docs.google.com/spreadsheets/d/1dCfShenhV2j98q5wkOXMeyWj9tlMZbaBgBqB2vAPdHo/edit?usp=sharing
I am looking to update H,I and J columns using vlook formula in way that it should match both name and date values in my data range, which in A,B and C columns
Here is the issue I am facing with normal vlookup is that I can check only name.It is ignoring the date and updating the vlooked up data on all date column.
Eg: Alpha and date 20141120 value is 10, it should fill only H3, but it is updating, H3 I3 and J3 with value 10
I really appreciate your answer on this problem!!!
you can use this formula of index and match:
=IFERROR(INDEX($A:$C,MATCH(1,($A:$A=$G3)*($B:$B=H$2),0),3),"")
paste it in the first cell of your table H3, and drag and fill to the right and then select the entire row and fill down till end.
it should work.
if error(();"") : you will get empty cells if there is no match.
this is an array formula, so press ctrl+shift+enter to calculate the formula
UPDATE: here is [the example sheet downloadable from here}(https://www.dropbox.com/s/clqxsj5j4bdk27b/indexmatch.xlsx?dl=0)
Basically you need to concatenate the results, then use a VLOOKUP on that.
I.e. insert a column between B and C, with formula "=CONCATENATE(A2,B2)"
In the range you want to update, use the column and row headings for you lookup
"=VLOOKUP(CONCATENATE($g3,h$2),$c$1:$d$3,2,false)"
You want to perform a Multiple Lookup (see this).
As indicated there, enter
=IFERROR(LOOKUP(2,1/($A$1:$A$3=$G3)/($B$1:$B$3=H$2),$C$1:$C$3),"")
in H3. Copy into H3:J5.
This avoids array formulas.