excel vlookup with multiple criteria - excel

Table 1 Table 2
A B C D
abc 9 abc No
hij 0 def yes
hij No
input output
abc 9
def #N/A
hij No
I have two tables. If the value exists in column A and the lookup value is greater than 0, then lookup in Table 1, else lookup in Table 2.
I have tried with the formula:
=IF(OR(ISERROR(VLOOKUP(A7,$A$2:$B$4,2,FALSE)),ISERROR(VLOOKUP(A7,$A$2:$B$4,2,FALSE)=0),VLOOKUP(A7,$A$2:$B$4,2,FALSE)=0),VLOOKUP(A7,$D$2:$E$4,2,FALSE),VLOOKUP(A7,$A$2:$B$4,2,FALSE))
Thanks for any help.

use this formula:
=IF(IFERROR(VLOOKUP(A7,$A$2:$B$4,2,0),0)>0,VLOOKUP(A7,$A$2:$B$4,2,0),VLOOKUP(A7,$C$2:$D$4,2,0))

Related

Excel Combining Countif and Vlookup

Table 1 (input):
Name
Value
Bob
0.5
John
1.2
Bob
0.3
John
0.1
Jane
3
Table 2 (expected output):
Name
>=0 & <1 Count
Bob
2
John
1
Jane
0
I'm looking to count the names in Table2 (column A) every instance in which the name appears in Table1 but only if their value columns in Table1 is between 0 and 1.
I'm assuming I have to combine VLOOKUP with COUNTIFS but I am not sure.. Nothing works..
NOTE: PivotTables are not an option, Table2 column B must have the right formula to count these instances with the two criteria applied. Likely ">="&0 and "<="&1 should be present in the formula.
Thank you for your help!
Just COUNTIFS:
=COUNTIFS(A:A,D2,B:B,">=0",B:B,"<1")

Excel Count rows where value in Column A has a duplicate in column B and that duplicate's other value in Column A equals something

Given the table below:
A
B
C
D
1
happy
1-veggies
GHF
1
sad
1-veggies
HGF
2
angry
1-veggies
GHG
2
sad
1-veggies
FGH
3
sad
1-veggies
HGF
4
moody
2-meat
FFF
4
sad
2-meat
HGF
5
excited
2-meat
HGF
I need to count the number of rows where C="1-veggies", B="sad", A has a duplicate within A and whose alternative rows in A have a value in D = "GHF" or "FGH".
The result should be 1 based on the second row.
The second row has B= "sad", C = "1-veggies", A has a duplicate within A, whose value is "1" and the 1st row, also with A = "1" has a value in D = "GHF".
I already have a formula as follows:
=SUMPRODUCT((B1:B8="sad")*(COUNTIF(A1:A8,A1:A8)>1)*(C1:C8="1-veggies")*(D1:D8="GHF"))
However, it isn't able to check the 1st row nor does it check the necessary OR statement on column D.
I don't know how to accomplish either task. Thank you.
Add some more COUNTIFS():
=SUMPRODUCT((B1:B8="sad")*(COUNTIF(A1:A8,A1:A8)>1)*(C1:C8="1-veggies")*(COUNTIFS(A1:A8,A1:A8,B1:B8,"<>sad",D1:D8,"GHF")+COUNTIFS(A1:A8,A1:A8,B1:B8,"<>sad",D1:D8,"FGH")>0))
Basically you want to select rows where C="1-veggies", B="sad" and join them to rows where D = "GHF" or "FGH", but with a condition that the value in column A is equal in both but the row number is unequal. This might be a good use of Power Query for users who are expert in this, but using formulas is problematic because of the limitations of countifs (has to be a range). A workaround if you have Excel 365 would be to use some filters followed by countifs:
Column E
=FILTER(A1:A8,(B1:B8="sad")*(C1:C8="1-veggies"))
Coumn F
=FILTER(ROW(A1:A8),(B1:B8="sad")*(C1:C8="1-veggies"))
Column G
=FILTER(A1:A8,(D1:D8="GHF")+(D1:D8="FGH"))
Column H
=FILTER(ROW(A1:A8),(D1:D8="GHF")+(D1:D8="FGH"))
Then
=SUM(COUNTIFS(E1#,G1#,F1#,"<>"&H1#))

Rank like Subtotals

It's possible use Rank like Subtotals, that only use de showing data?.
If I filter data by a column, I want than Rank function only use these datas
Example
A B C The column C its Rank of column B
a 5 3
b 9 1
a 2 4
c 7 2
Now if I apply a filter in column A for value 'a'
A B C I want the rank recalculate with this new data
a 5 1 --> column C change from value 3 to value 1
a 2 2 --> column C change from value 4 to value 2
Thanks
You cannot do it by using RANK() formula, but you can create customizable rank formula. For this, You should add column at the and of table to indicate the row visibility, and put this formula into this column:
=(AGGREGATE(3;5;B2)>0)+0
Then put this formula into column C:
=SUMPRODUCT(($B$2:$B$9<B2)*($E$2:$E$9=1))+1
To check real example, download my sample file

Excel concatenate the column based on other column

I have data in excel like this
A B C
p1 ABC 2
p2wt ABC 3
p3 EFG 1
p3wtke EFG 1
p9r EFG 2
I'm trying to sum up C column if B column has same data and concatenate A column data. And data looks like
A B C
p1-p2wt ABC 5
p3-p3wtke-p9r EFG 4
I tried using =SUMIFS(C1:C5,A1:A9,B1) but it is giving #value, and how do i concate A? I tried Excel concatenate, but is A2>A1 in this link is for number fields?
Use a helper column.
In D1 put:
=IF(B1<>B2,A1,A1&"-"&D2)
Then copy/drag down the data set.
The in another column create a list of the unique values in column B. I put mine in G.
Then in F1 I put:
=VLOOKUP(G1,B:D,3,FALSE)
And in H1 I put:
=SUMIF(B:B,G1,C:C)
Then copies/dragged down.

Adding corresponding column A values if values in column B match one another

I need to create a formula that adds up column A if the values in column B match.
A B
1 123
1 123
2 345
2 345
1 345
So for this example I need it to add up 123's to show 2 and 345's to show 5. I have been playing with SUMIF and VLOOKUP but haven't been able to get it to work.
In row2 and copied down to suit:
=SUMIF(B:B,B2,A:A)

Resources