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

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

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 extract unique values from one column based on criteria from two other columns, with or statement?

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.

Logic function to combine all matching text into one cell

I am looking for help with a formula that looks for all matching text and combines the results into a single cell. For example if the Country is Colombia I want a single cell to list all of the names that match Colombia.
ColA ColB
A1: COUNTRY NAME
A2: Argentina John Doe
A3: Bahamas Jan Doe
A4: Colombia James Doe
A5: Colombia Jason Doe
A6: Colombia Julian Doe
I've toyed around with CONCANTENATE and MATCH however they don't seem to be getting me what I need.

COUNTIF/MATCH after date

What I'm essentially looking to do is be able to track to see how many refills our patients have received. I have a list of what was sent to the pharmacy, and what the pharmacy has returned. What I would like to do is fill in Column C on Sheet 1, which will track if the patient received any refills after their initial prescription fill. As below, patients can get more than one prescription in any month for different drugs. All I'm looking to do is count how many months they received something after their first month's fill.
In this example, Patient John would have 2 months of refills, Adam would have 0 (or No fills at all), Bob would have 0 refills, and Phil would have 1 refill month.
Thanks!
Sheet 1
A B C
Date Patient Refills
1/1/18 John
1/2/18 Adam
1/3/18 Bob
1/4/18 Phil
Sheet 2
A B C
Date Filled Patient Prescription
1/10/18 John Drug A
1/10/18 John Drug B
1/12/18 Bob Drug A
1/12/18 Bob Drug B
1/12/18 Bob Drug C
1/13/18 Phil Drug C
2/10/18 John Drug A
2/10/18 John Drug B
2/13/18 Phil Drug C
2/13/18 Phil Drug D
3/10/18 John Drug A
Well here are a couple of formulas which go some way towards addressing the problem.
The first one is just a standard formula for counting the number of different dates for John which can be pulled down for the other patients
=MAX(SUM(--(FREQUENCY(IF(B$2:B$12=F2,A$2:A$12),$A$2:$A$12)>0))-1,0)
The next one is counting the number of different months for John, and can also be pulled down for the other patients. In this case, two different dates for the same patient in the same month would be counted as one:
=MAX(SUM(--(FREQUENCY(IF(B$2:B$12=F2,MONTH(A$2:A$12)),MONTH($A$2:$A$12))>0))-1,0)
Both these have to be entered as array formulas using CtrlShiftEnter
I have changed the data slightly to show the difference between the two formulas
Note that these formulas have limitations as mentioned in the comment, where the prescription dates might split across the end of a month in your real data, or if they span multiple years, in which case you would need a more sophisticated approach.
on sheet1, column c2
=COUNTIFS(Sheet2!B:B,Sheet1!B2,Sheet2!A:A,">" & A2)

Count repetitive values in column B based on unique value in column A

I have the following table:
1 John Doe
John Doe
2 Adam Smith
Adam Smith
Adam Smith
I need to count the number of times a name appears for each number value in column A. The numbers are unique.
Place this formula in cell C1 and drag down until the end.
=IF(ISNUMBER(A1),COUNTIF(B:B,B1),"")
n.b. - you can more clearly define row numbers instead of using B:B if you like as well

Resources