Match Value in Cell to an Existing Column and Return Adjacent Cell Text - excel

I have a spreadsheet containing patients in column a, patient's diagnosis in column b, and their doctor in column c. I have another sheet that has the doctors listed in column a and their practice group in column b. I need a function that will look at each value in column c on sheet 1, match it to the doctor in column a on sheet 2 (Doctors List), and return the practice group to column d on sheet 1. I have tried a few formulas including this one
=IFERROR(VLOOKUP(C2,'Doctors List'!A:B,2,FALSE),"")
but can't seem to get anything to work! It just returns blanks. Please help!
**SHEET 1
Patient Name Diagnosis Attending Physician Practice Group**
Patient A Diagnosis Dr. Smith
Patient B Diagnosis Dr. John
Patient C Diagnosis Dr. Joe
Patient D Diagnosis Dr. Ken
Patient E Diagnosis Dr. Williams
Patient F Diagnosis Dr. Williams
Patient G Diagnosis Dr. Smith
Patient H Diagnosis Dr. Jones
**SHEET 2
Physician Practice Group**
Dr. Smith Practice A
Dr. John Medical Group A
Dr. Joe Practice B
Dr. Ken Medical Group B
Dr. Williams Practice C
Dr. Jones Medical Group C

Try using MATCH and INDEX rather than VLOOKUP
So in D2 of sheet 1:
=INDEX(Sheet2!$B:$B,MATCH($C2,Sheet2!$A:$A,0))
and copy that formula down.
If you're looking to troubleshoot, your existing formula, try using "Evaluate" on the Formulas tab of Excel 2010 which can step you through the calculation.
I've had problems with text fields that have extra spaces after them, so I regularly use the "TRIM" function when doing lookups, or matches.

Related

Excel Function - If string from column A is found in Column B Then

Column A has a list (first and last names) of all users who have an O365 license. Column B has a list of everyone in the company. Column C is associated with Column B and has the job title of everyone in the company.
I want each row in A to check all of B to see if they match. If they match I want to take the corresponding row in column C and copy/paste it into the same row in blank column D
A (O365 License
B (All Employees
C (Job Title).
D (JobTitle)
John Smith
Jarvis Cobblepott
. IT Guy
Nancy Johnson
John Smith
. Receptionist.
Kevin Gordon
Henry Kissinger
Marketing
Use ISNUMBER(MATCH()) to see if it exists:
=IF(ISNUMBER(MATCH(B2,A:A,0)),C2,"")
Alternatively maybe:
=XLOOKUP(A2,B$2:B$4,C$2:C$4,"",0)
Or:
=BYROW(A2:A4;LAMBDA(r,X.XLOOKUP(r,B2:B4,C2:C4,"",0)))

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

Excel - Append cell2 to cell1 if cell3 is not blank

All,
I've taken a browse around and I've been unable to nail down the formula I'm looking for. I'm a bit new to Excel expressions, so this is all part of the learning process.
My quandary:
I have a list of names in an Excel spreadsheet - some have two components and some have three. I need all names to have only two components - if they have three, then the first two components need to be combined.
Here is my workflow:
IF cell 3 is occupied, append the content of cell 2 to the end of cell 1 IN cell 1. Then, assuming cell 2 is now blank, move the content of cell 3 to cell 2. Else, do nothing.
So my input might be (assuming each group of characters is in its own cell):
JOHN SMITH
JOHN DOE SMITH
BARRY JOHNSON
RICHARD P RICKSON
JACK JACK GILES
My output would be:
JOHN SMITH
JOHNDOE SMITH
BARRY JOHNSON
RICHARDP RICKSON
JACKJACK GILES
What's your take on this?
Assuming your data is in columns A, B, and C, this will put the correct output in columns D and E.
In column D:
=IF(ISBLANK(C1),A1,CONCAT(A1,B1))
In column E:
=IF(ISBLANK(C1),B1,C1)

MS Excel: IF and AND nested

Can someone help with simple excel look up function: How can I pull assigned doctors from the table?
All other cities
and countries Chicago Boston Atlanta California Dallas
General Lee John
Pediatrics Greg
Dermatology Greg Peter Lee
Optholmol Greg
Radiology Mary
Surgery Greg Mary Greg
For ex., Dermatology and Boston should return Peter, but Dermatology from any other city should return Greg
This is a Formulaic answer (no macros or VBA):
If you have a table set up like this:
And on another sheet or range you desire this as your output:
You can use this formula, assuming that the input is in A2 and B2, and the table is on Sheet2 in the range of A2:G8:
=IF(
IFERROR(
INDEX(Sheet2!A2:G8,MATCH(A2,Sheet2!A2:A8,0),MATCH(B2,Sheet2!A2:G2,0)),0
)=0,
INDEX(Sheet2!B2:B8,MATCH(A2,Sheet2!A2:A8)),
INDEX(Sheet2!A2:G8,MATCH(A2,Sheet2!A2:A8,0),MATCH(B2,Sheet2!A2:G2,0))
)
To explain:
The formula: INDEX(Sheet2!A2:G8,MATCH(A2,Sheet2!A2:A8,0),MATCH(B2,Sheet2!A2:G2,0))=0 will test to see if a Doctor exists for the given pair of lookup values.
This formula is getting the row and column value from the array specified:
IFERROR(INDEX(Sheet2!A2:G8,MATCH(A2,Sheet2!A2:A8,0),MATCH(B2,Sheet2!A2:G2,0)),0)=0
^^ array ^^ ^^ match the row ^^ ^^ match the column ^^ ^^ True if no doctor is found
If no doctor exists then we can return a lookup from B2:B8 which is the "All other cities and countries list": INDEX(Sheet2!B2:B8,MATCH(A2,Sheet2!A2:A8))
If one does exist we can just output that doctor: INDEX(Sheet2!A2:G8,MATCH(A2,Sheet2!A2:A8,0),MATCH(B2,Sheet2!A2:G2,0))

Resources