How to extract unique values from one column based on criteria from two other columns, with or statement? - excel

My data set looks something like this:
ID Name1 Name2
1 Jack Tom
1 Tom Tom
1 Lisa Tom
2 Tom
2 Tom
3 Frank Frank
3 John Frank
3 Frank Frank
3 John Frank
4 Tom
4 Tom
5 Lisa
5 Jack
and I want the following output:
Result
1
2
4
Note: I want the unique IDs for Tom if "Tom" shows in one of the two name columns.
I tried to use the following formula:
IFERROR(INDEX(INDIRECT($B$14); MATCH(0; IF($B$10=INDIRECT($B$16); IF($B$10=INDIRECT($B$15); COUNTIF($E$27:E27; INDIRECT($B$14)); "")); 0));"")
The problem is that this only gives me ID nr 1 as output since Tom shows up in both columns in this case. I think I need to implement an OR-statement to the formula.
Explanation of my formula:
Indirect(B14): array for the call IDs. B14 contains a name of this array.
B10: Contains the name I want to match (i.e. "Tom")
Indirect(B16): column Name1
Indirect(B15): column Name2
Good answers will be rewarded:)

I used your formula (without INDIRECT statements) and added ISNUMBER & FIND in order to find "Tom" in a combination of columns B and C:
This is an array formula (Ctrl+Shift+Enter):
=IFERROR(INDEX($A$1:$A$14,MATCH(0,COUNTIF($F$1:F1,IF(ISNUMBER(FIND("Tom",$B$1:$B$14&$C$1:$C$14)),$A$1:$A$14,"")),0)),"")
Result:
I couldn't use INDIRECT references as I'm not sure what exactly they point to (i.e. what are the ranges & column names). I hope it won't be too difficult for you to modify my formula in order to match your references.
Hope it helps! Cheers.

Related

Get multiple values in a single cell with array formula

I'm trying to get an array formula to get the multiple results in a single cell. Is that possible?
For example below, I'd like to show in D2 all the names in column B corresponding to rows for values less than 4 in column A.
My current attempt below:
A C
2 Jane
3 John
6 Thomas
1 Michael
2 Mary
7 Jason
3 Gloria
1 Andrea
=CONCAT(INDEX($B$2:$B$9,IF($A$2:$A$9<4,$B$2:$B$9)))
My desired result would be:
Jane, Michael, Mary, Andrea
You need FILTER() then TEXTJOIN().
=TEXTJOIN(", ",TRUE,FILTER(B2:B9,A2:A9<4))

How to unpivot a data using excel formula

I have a table as below,
Column A
Column B
Tom
12,45
Kenny
1,4,6
Jude
1,4,5,7
Benji
15,48
Need it like as below
Column A
Column B
Tom
12
Tom
45
Kenny
1
Kenny
4
Kenny
6
Jude
1
Jude
4
Jude
5
Jude
7
I have tried using the FILTER function, however it is not providing what I need.
Office 365. assuming a range of A1:B4 (change as required within the formula):
=LET(ζ,A1:B4,κ,INDEX(ζ,,1),λ,INDEX(ζ,,2),α,"<a><b>",β,"</b><b>",γ,"</b></a>",δ,"//b",ξ,FILTERXML(α&TEXTJOIN(β,,SUBSTITUTE(λ,",",β))&γ,δ),IF(SEQUENCE(,2,0),ξ,INDEX(FILTERXML(α&CONCAT(REPT(κ&β,1+LEN(λ)-LEN(SUBSTITUTE(λ,",",""))))&γ,δ),SEQUENCE(COUNT(ξ)))))
It is assumed that there are no names in column A with a corresponding blank in column B.

Excel table Lookup values

I have a table-1 like this:
NAMES ID
John 1
Bill 2
May 1
Silvia 1
Sam 3
Oren 2
Another table-2:
ID_To_Compare name1 name2 name3
1
2
3
I would like to have in table-2 function that gets result like this, according to ID_To_Compare (seeks it in table-1):
ID_To_Compare name1 name2 name3
1 John May Silvia
2 Bill Oren
3 Sam
An Excel lookup looks like this;
=VLOOKUP(I7;Sheet1!$A$2:$F$250;2;FALSE)
The first part (I7 in this case) is the value of the key to find.
The second part (Sheet1!$A$2:$F$250 in this case) is the range to search in.
The third part (2 in this case) is the column index of the queried range from which the value should be read.
The last boolean tells whether or not it is a range lookup (in this case we're after a single value).
With your sample data:
Formula in cell B10:
=IFERROR(INDEX($A$1:$A$7,SMALL(IF($B$1:$B$7=$A10,ROW($A$1:$A$7),""),COLUMN(A1))),"")
Confirm through CtrlShiftEnter
Drag down and right...

Excel: match value from an array and return cell value from the same row

I have some data in excel worksheet1 in this form:
person1 person2 person3 score
dave sarah jill 4
brandon hank 3
And in worksheet2 I have a column of people listed alphabetically, like this:
person score
alex
brandon
dave
hank
jill
sarah
I'd like to obtain each person's score from worksheet1 (with blanks for those who are absent):
person score
alex
brandon 3
dave 4
hank 3
jill 4
sarah 4
I've looked into functions like find, match, lookup, vlookup, but it seems like I will need something more complicated.
Assuming:
Each person can only ever occur once in the source data
The source data occupies the range A1:D3 (with headers in row 1)
The first person's name for which you wish to return a result is in G2
then this formula in H2:
=IF(COUNTIF($A$2:$C$3,G2),INDEX($D$2:$D$3,SUMPRODUCT(($A$2:$C$3=G2)*(ROW($A$2:$C$3)-MIN(ROW($A$2:$C$3))+1))),"")
Copy down to give equivalent results for names in H3, H4, etc.
Regards

If column has duplicate values then check duplicate in another column

I have two column I and N.
In column I have 6 digit numbers.
In column N have names.
I N R(Result)
123456 James BLANK
123456 Mike BLANK
111111 Jack Jack&111111
111111 Jack Jack&111111
000023 Mike Blank
000024 James James&000024
000024 James James&000024
I tried so far but not working
=IF(COUNTIF(I:I,I2)>1,IF(OR(N2=N1,I2=I1,I2=I3),CONCATENATE(I2," ",N2),""),"")
Try using the formula:
=IF(COUNTIFS(I:I, I2, N:N, N2)>1, I2&" "&N2, "")
COUNTIFS allows you to enter multiple criteria for the count, as opposed to COUNTIF.

Resources