My table
Id index Col1 col2 col3
a 1 smith
a 2 John
b 1 mark
b 2 kay
b 3 Van
c 1 Par
c 2 Cap
In the Vlookup Table
ID Col1 Col2 Col3
a Smith John
b Mark kay Van
c Par Cap
How do I achieve by doing vlookup by id
I believe this will solve your issue:
This is the formula in cell I2:
=INDEX($C:$C,MATCH($H2,$A:$A,0))
This is the formula in cell J2:
=IF(INDEX($D:$D,MATCH($H2,$A:$A,0))=0,OFFSET(INDEX($D:$D,MATCH($H2,$A:$A,0)),1,0))
This is the formula in cell K2:
=IF(INDEX($E:$E,MATCH($H2,$A:$A,0))=0,OFFSET(INDEX($E:$E,MATCH($H2,$A:$A,0)),2,0))
Hope this helps!
Thanks.
If you want to use vlookup instead of index and match, you could use a helper column:
The formula in cell 1 is:
=B2&C2
The formula in cell H2 is:
=IF(ISERROR(VLOOKUP($H2&RIGHT(I$1,1),$A$2:$C$8,RIGHT(I$1,1),0)),0,VLOOKUP($H2&RIGHT(I$1,1),$A$1:$F$8,RIGHT(I$1,1)+3,0))
To make the formula be the same in all cells in the output table, I have used the rightmost character in the column name as an index. Hard coding this value, or adding a helper row, would make it easier to read.
Related
The table structure that I have right now is as below:
Column A Column B
Apple 1
Apple 2
Apple 1
Orange 1
Orange 2
I am trying to write a formula where, for all the cells with the value of Apple in column A, I get the total count for values in column B equal to 1.
Please help.
As far as I can tell, you are just after the formula
=COUNTIFS(A:A,"Apple",B:B,1)
I've an excel with 2 sheets, the sheet 2 has some KV, my requirement is that, when I enter a key in sheet 1, it should get the corresponding values (spread across many columns & rows).
Sheet2:
A B C D
1 Obj1 Item1 Price1 Qty1
2 Item2 Price2 Qty2
3 Item3 Price3 Qty3
4 Item4 Price4 Qty4
Note: Obj1 is merged for 4 rows in col1.
In Sheet1 if I enter Obj1, I want all the values present in column B, C, D & the rows 1, 2, 3, 4.
I tried the option
{=vlookup("Obj1", Sheet2!A:D, {2,3,4}, false)}
But does not return 3 columns as expected. (I read this method of returning multiple columns in some website)
Kindly help me to resolve this.
Use a helper column:
In E1 put:
=A1
In E2 put
=IF(A2<>"",A2,E1)
Then put this formula in the upper left corner of the desired output range:
=IFERROR(INDEX(B$1:B$4,AGGREGATE(15,6,ROW(B$1:B$4)/($E$1:$E$4=$G$1),ROW(1:1))),"")
Where $G$1 is the location of the Search Criteria.
Then drag/fill this formula across a total of three columns and down enough rows to cover the greatest number of rows that a object can have.
Of course once you have your helper column you can easily use it with filters to output the same thing without the formulas.
I have 4 columns of data. I want to match the values of two of the columns then if take the difference of two other columns if the first two match. So it's accounts and amounts.
Example. If col A matches Col C take the difference of Col B and Col D and Out it in Col E
Col A Col B Col C Col D Col E
1234 $100 1234 $100 $0
1235 $120 1235 $150 $-30
1236 $150 1237 $150
1238 $130
=IF(A1=B1,C1-D1,)
A1 and B1 are cell references to values you are comparing, and C1 and D1 are cell references to the values you are trying to take the difference of. If you'd like to have the cell be blank instead of 0, add "" after the last comma.
Assuming first data row to be A2:E2, Please put below mentioned formula in cell E2
=IF(A2=C2,B2-D2)
Similarly you can do reverse action by like if it is not then add them or put 0 or blank by "" or subtract B2 from D2 by below given options.
=IF(A2=C2,B2-D2,B2+D2)
=IF(A2=C2,B2-D2,0)
=IF(A2=C2,B2-D2,"")
=IF(A2=C2,B2-D2,D2-B2)
Hope this would help!
I want to fill in one cell with text based on another cell that has a number. So for example if A1 reads 2 I want B1 to read Correct.
In my case I have multiple possible criteria, B1 = Correct is just ONE example.
Will this be a conditional format formula involving an IF function or vlookup possibly?
Basically what I'm looking to do is IF A1 = 2, than B1 = Text
Thanks in advance for an answer to this
Use a VLOOKUP formula
to do this you need a table of key and value
for example
in the range d1:E6 you have the lookup table.
Lookup LookupValue
1 May be correct
2 Don't know
3 It depends
4 probably correct
5 My wife says it is correct
In the range a1:c7 you have your data
col1 col2 col3
kjkjk 2 Don't know
klkl 2 Don't know
jkljkjk 1 May be correct
kjukjkjk 4 probably correct
lklklkl 5 My wife says it is correct
lklklkl 3 It depends
in col3 you use the VLOOKUP
as =VLOOKUP(B2, MyLookupTable, 2)
Note that I named the d1:e6 range as MyLookupTable
THis is what it looks like
How to do numbering/sequencing for sets of same column values? For example:
Col1 Col2
Andy 1
Chad 1
Bill 1
Andy 2
Bill 2
Bill 3
Chad 2
Bill 4
Since Andy got 2 values, I want to number it 1 and 2 in Column 2. For Bill, I want to number it 1, 2, 3 and 4 and so on.
You can accomplish this with countif and a sliding range :
A B
1 val1 =COUNTIF($A$1:A1, A1)
2 valx =COUNTIF($A$1:A2, A2)
and so on.
The formula in column B can be dragged down / autofilled in the column. It anchors to the start of the range and only looks as far down as the value we are numbering; COUNTIF is tallying up the matching values in the preceding set this way.
That is kind of slow when your list is really long. I've found sorting the column A to Z or small to larger and then using this formula is much faster:
=IF(A2=A1, A1+1,1)
Basically
if the value above is the same then add one to the count else start over at 1