IF multiple criteria with VLOOKUP - excel

I cant fix my formula. Or better i dont even know if im on right way.
My geal is: row B is empty, there will be formula.
A B C D
1 ID TYPE ID_Criteria
2 1 FIRM 4
3 0 HUMAN
4 3 FIRM
5 4 CORPORATE
IF A2 > 0 then VLOOKUP in row D, if false B2 is FIRM. Otherwise IF A2 > 0 then VLOOKUP in row D and TRUE B2 is CORPORATE. And last condition when A2 < 0, row return Human.
My formula:
=IF(A2>0,IF((VLOOKUP(A2,D1:D4,1,0),"CORPORAT","FIRM"),"HUMAN"))
Any ideas ?

Use
=IF(A2>0,IF(ISNUMBER(MATCH(A2,$D$1:$D$4,0)),"CORPORATE","FIRM"),"HUMAN")

Related

Excel-Is is able to return current result if the condition fails

Below table describes what I expect for.
The "Count Blank" Column is a counter for counting continuous blank cells in order from Column A to Column C. If any of the following cell has value then stop counting and return current value. (plz see row6 and row7)
Basically, I'm looking for a formula which could return the current counter value if the condition fails.
Count Blank
Column A
Column B
Column C
0
1
2
3
1
2
3
2
3
3
1
2
0
1
These two formulas are just for counting the blank cells in the range:
=COUNTIF(B8:D8,"")
=SUM((IF((B8:D8)="",1,0)))
Hoping anyone can help with the continuous problem.
Count Blank
Column A
Column B
Column C
0
1
2
3
1
2
3
2(should be 1)
2
2(should be 0)
1
I found this: https://exceljet.net/formulas/get-first-non-blank-value-in-a-list
You don't really want to count anything, you just need to find the first non blank cell. You can try this formula:
=IFERROR(MATCH(FALSE;ISBLANK(B2:D2);0)-1;COLUMNS(B2:D2))
This is an array formula, so press ctrl+shift+enter when entering it into a cell.
You can use the new (as of 2020) reduce and lambda functions:
=VALUE(REDUCE(0, B1:D1, LAMBDA(prev, curr, IF(ISTEXT(prev), prev, IF(curr = "", prev + 1, TEXT(prev,"0"))))))

Google Sheets - formula to return N first values from range A where MAX(range B)

F1:N1 with random numbers (can have duplicates).
F2:N2 with sorted numbers.
Need a formula to fill in A1:C1 with values from F2:N2 where F1:N1 has a maximum value.
In the example it should be 1,8,3 from F2:N2 - according to 9,9,8 from F1:N1.
_ A B C D E F G H I J K L M N
1 ? ? ? 9 3 8 1 5 5 3 9 8
2 1 2 3 4 5 6 7 8 9
You can do this with a "helper row" to create a list of unique ranks:
F3: =RANK(F1,$F$1:$N$1)+COUNTIF($F$1:F1,F1)-1
and fill right to N3
Since your values in F2:N2 are sequential {1...8}, you can use this formula:
A1: =MATCH(SMALL($F$3:$N$3,COLUMNS($A:A)),$F$3:$N$3,0)
and fill right to C1
If the values in F2:N2 are random, then you can use this:
A1: =INDEX($F$2:$N$2,1,MATCH(SMALL($F$3:$N$3,COLUMNS($A:A)),$F$3:$N$3,0))
and fill right to C1
Nobody has jumped in to offer a Google Sheets solution so here is one:
=query(transpose(sortn(transpose(F1:N2),3,,1,false,2,true)),"select Col1,Col2,Col3 limit 1 offset 1")
In A1. This is a self-expanding formula so does not need to be filled across and does not need helper rows.
EDIT
'Limit 1' may be omitted in the above formula as mentioned in the comment.
Also this is a little shorter:
=transpose(query(sortn(transpose(F1:N2),3,,1,false,2,true),"Select Col2"))
Formula in A1 = INDEX($F$2:$N$2,MATCH(COLUMN(A1),$F$3:$N$3,0)) and is dragged till C1
Formula in F3 = RANK(F1,$F$1:$N$1)+COUNTIF($F$1:F1,F1)-1 and is dragged till N3

How to match columns and adding blank rows in excel

I have an excel file with 5 rows in column A and B, and 3 in column C and D (in reality though, I have a couple of hundreds of rows). Column B consists of text belonging to A, and D of text belonging to C. Column C has some of the values found in column A.
It looks like this:
A B C D
1 1 stringA1 1 stringC1
2 2 stringA2 2 stringC2
3 3 stringA3 4 stringC3
4 4 stringA4
5 5 stringA5
Now, I would like to match the numbers in column C with those in A, so that matches are put in the same row. For those rows in A for which there is no match in C, I want to have blank cells after column B.
It would look like this in this case:
A B C D
1 1 stringA1 1 stringC1
2 2 stringA2 2 stringC2
3 3 stringA3
4 4 stringA4 4 stringC3
5 5 stringA5
I have some idea that I should use VLOOKUP and maybe Conditional Formatting, but unfortunately I am not very experienced in excel. Could someone please suggest a way to do this?
Enter the following formula in Cell E1:
=IF(IFERROR(MATCH(A1,$C$1:$C$5,),"")<>"",INDEX($C$1:$D$5,IFERROR(MATCH(A1,$C$1:$C$5,),""),1),"")
and this one in Cell F1:
=IF(IFERROR(MATCH(A1,$C$1:$C$5,),"")<>"",INDEX($C$1:$D$5,IFERROR(MATCH(A1,$C$1:$C$5,),""),2),"")
Using Helper Column:
You can also do this using a helper column.
In Cell E1 write:
=IFERROR(MATCH(A1,$C$1:$C$5,),"")
Then in Cell F1 write:
=IF(E1<>"",INDEX($C$1:$D$5,E1,1),"")
And finally in Cell G1 write:
=IF(F1<>"",INDEX($C$1:$D$5,E1,2),"")
This was answered by #user3514930 to a question here.
You can directly use this formula in D2 and copy downwards:
=IF(A2 = C2, A2, "")
Now if you have formulas in A2, C2, type in those formulas in place of A2, C2 in the above.

How to return multiple values using index/match?

I have the below simple table:
A 1
B 2
C 2
D 1
Using an index/match formula, I have set it up so that it only looks at one row at a time.
However, when I drag this formula down and ask it to return where the second column is a 2. I receive N/A at the top and bottom of my lookup.
Is there a way for me to ask it to skip when there is a NA or return multiple rows?
Here is my code:
=INDEX(B2,MATCH(1,C2))
Which returns:
A 1 A
B 2 #N/A
C 2 #N/A
D 1 D
I would like it to return:
A 1 A
B 2 D
C 2
D 1
So skiiping rows where there is no match.
The easiest way to have it skip what the value is NA is to either put an IF statement
=If(A1 = "NA","",INDEX(MATCH))
or
If it is NA because it is not finding a match
=IFERROR(INDEX(MATCH),"")
one of those 2 should do it. If not please post your code.

A function that will lookup a reference

Before I get started thanks for taking your time and helping.
This is what my worksheet looks like:
Row # B C D E F
2 1 Product 1 B2 B3 B4
3 2
4 6
5 1 Product 2 B5 B6
6 5
7 4 Product 3 B7
I was trying to follow this formula: (The best answer one or green check mark) return values from multiple matching rows
I got all the way to the =IFERROR(INDIRECT(lookups!H5),"") but can not get this to work.
What I am tying to do is order the numbers in Column B to go to the right of the product. Which I was able to get the column it is in (B) and the row number it is in (B2). I would like to change the value (B2) to the number that is there.
I would like it to look like this:
Row # C D E F
2 Product 1 1 2 6
3
4
5 Product 2 1 5
6
7 Product 3 4
If someone could help explain this to me or find a better way that would be great.
Not sure what is to happen to columnB but if you replace B with "="B throughout columns D:F then select each of these in turn and apply Text to Columns with Tab as the delimiter the 'cell references' convert to formulae referring to the values in B. If you want to delete columnB copy D:F and Paste Special, Values over the top.

Resources