I am trying to lookup data, using optional criteria.
For example the input data may be :
Col1 Col2
Pig Mouse
and the lookup table :
Col 1 Col2 Col3
Pig 1
Pig Mouse 2
So this example would return 2. If just Pig was in the input data, it would return 1
=SUMPRODUCT(($A$7:$A$8=A2)*($B$7:$B$8=B2)*($C$7:$C$8))
This will return every value from columnC where ColumnA = A2 and ColumnB = B2, even if the values are blank.
Related
I was hoping someone can help me with a formula.
What I am trying to do is format a number as currency if the column 3 to its left contains a specific text.
For example,
Col1, Col2, Col3
YES a 5$
NO b 4
YES c 3$
In this case 5 and 4 are formatted as currency since their corresponding Col1 is YES.
Use:
=$A1="YES"
As the formula and apply it to Column C
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.
As shown in the image in Col2 I need to get the count of not null values in the Col1 before the cell.
For cell B2 there is only one value A hence 1.
For cell B4 it should be 2 as there are 2 values A & C.
Same way for B5, 3 (A,C,D)
Data:
A B
1 Col1 Col2
2 A 1
3
4 C 2
5 D 3
6
7 F 4
I have tried:
B1 Cell = COUNTA(A2:A2)
B2 Cell = COUNTA(A2:A3)
B3 Cell = COUNTA(A2:A4)
However I cannot drag this formula as it will change the cell reference.
Can anyone suggest any way to get this done in a single formula which can be applied to all the cells through out the column.
Try this:
=IF(A2<>"",COUNTA($A$2:A2),"")
I need to count the number of duplicate occurrences of values in a column using excel, ONLY for rows with a certain value in second column i present.
Column1 Column2
value1 x
value1 x
value1 x
value1
value2 x
value2
value3 x
---> should give
VALUE Occurencies
value1 3
value2 1
valu3 1
How to do this?
Thanks!
You can use a pivot table, which does not require any typing of values or any formulas.
Drag column1 into the row area and column2 into the values. If it is text, it will be counted. If the other values in column 2 are blank you are done. If they contain values, you can drag column2 into the filters area and then use the filter dropdown above the pivot table to select what value in column2 to use.
After you add new data to columns A and B, select the pivot table and refresh it.
If Column1 is in A1, please try:
=COUNTIFS(A:A,D2,B:B,"<>")
copied down to suit where D2... contain Value1 etc
I'm trying to query an excel worksheet using ADODB. The problem is there are many columns with a similar name and I'm unable to select the correct column in my query. Is there a was to select the column by using its range? Something like
select [A:A],[AB:AB] from [Sheet1$]
The source worksheet kind of looks like this
A B C D E F G H I
1 08/19/2013 08/18/2013 08/17/2013
2 Col1 Col2 col3 col4 col5 col3 col4 col5 col3
3
When I try to import all the data I get all the data minus the column names, only col1 and col2 are fetched. Its the same when I do from [Sheet1$] and from [Sheet1$A2:K100]
If there are multiple columns with the same or similar names, Excel/ODBC will probably do some funky name-mangling to make sure they are different in the recordset. What I would do is get all the columns with "SELECT *" then examine the fields names in the result set - then you can go back and retrieve by name just the columns you want.