Formula for helper column(s) that determines singular or combined values - excel

I am creating helper columns to assist me in reviewing our data, but I am running across an issue with one. What I am trying to accomplish is to create a helper column that tells me, by month, what type of medications a person is prescribed, and then combines multiple selections for the same name into a new name.
A sample data set would be:
A B C
1/1/2016 Doe, John Oral
1/1/2016 Doe, John Compound
1/1/2016 Doe, John Oral
2/1/2016 Smith, Jane Oral
2/1/2016 Smith, Jane Oral
2/1/2016 Adams, Tom Compound
2/1/2016 Doe, John Oral
So, for example, if John Doe was prescribed 2 oral medications and 1 compounded medication on 1/1/2016, the helper column would sort out that the three medications belong to the same person and are of two different types, so changes them to Combined. It would end up something akin to "1-Doe, John-Combined", displayed here:
D
1-Doe, John-Combined
1-Doe, John-Combined
1-Doe, John-Combined
2-Smith, Jane-Oral
2-Smith, Jane-Oral
2-Adams, Tom-Compound
2-Doe, John-Oral
So far, all I have is the concatenation by month:
=MONTH(A2)&"-"&B2&"-"
But I am not certain how to tackle the portion of the formula that will present the type of medication and combine (if required). Also, if necessary, more than one column can be created.
Thank you in advance.

Use SUMPRODUCT to test:
=MONTH(A1) & "-" & B1& "-" & IF(SUMPRODUCT((MONTH($A$1:$A$7)=MONTH(A1))*($B$1:$B$7=B1)*($C$1:$C$7<>C1))>0,"Combined",C1)

Related

Split Names in Excel using multiple characters

I've had some luck modifying formulas I've found on this site to separate names in a spreadsheet but I need some help. Can anyone suggest the best way to achieve my goal?
I have a "Tenant" column where each row contains from 1 -5 names, separated by commas and "&".
My data is pretty consistent so there is no need for error routines and it looks like these examples with the max # names being 5:
John Doe, Mary Smith, Rachel Reyes & Ben Thompson
or
John Doe & Mary Smith
or
John Doe, Mary Smith & Rachel Reyes
What I really want to do is separate each name into it's own column and then separate each first name into a another column. I would have a total of 5 columns for full names and 5 more for first names for up to 5 max names if that makes sense.
So for this data: John Doe, Mary Smith, Rachel Reyes & Ben Thompson
Column:
|A|B|C|D|E|F|G|H|I|J|
John Doe|John|Mary Smith|Mary|Rachel Reyes|Rachel|Ben Thompson|Ben|
Any help is appreciated.

Excel find duplicates in two tables and display related data

Let's say I've got two tables with two columns. In both cases, the first column consists of a name and a second column consist string of characters with the similar pattern. It looks like this:
Table 1
Peter xxxxx01
John xxxxx01
Bill xxxxx01
William xxxxx01
Table 2
Richard xxxxx02
John xxxxx02
Bill xxxxx02
Arthur xxxxx02
Now, I'd like to compare these two tables, find values where the names are duplicated and display data stored in second columns, just like this:
(Peter excluded)
John xxxxx01 xxxxx02
Bill xxxxx01 xxxxx02
(William, Arthur excluded)
I am familiar with pivot tables, however, it won't allow doing this.
I've also tried messing with index match formulas but without much success.
Any advices?
You can use the VLOOKUP function for this.
If your "Table1" is in B3:C6, and your "Table 2" is in F3:G6, then you can use the following formula in D3:D6 to lookup the values in table 2;
Cell D3: =IFERROR(VLOOKUP(B3,$F$3:$G$6,2,FALSE),"")
This is first looking up the name in table 1 (Cell B3) against table 2 (F3:G6), and returning the second column of table 2 if it finds the name. If it doesn't find the name, it will return an error, so we wrap the VLOOKUP in an "IFERROR" function, and replace any errors with an empty string, so it looks a bit friendlier. This results in the following table;
A B C D E F G
1
2 Table 1 Result Table 2
3 Peter xxxxxx01 Richard xxxxxx02
4 John xxxxxx01 xxxxxx02 John xxxxxx02
5 Bill xxxxxx01 xxxxxx02 Bill xxxxxx02
6 William xxxxxx01 Arthur xxxxxx02
You can then filter on the (Non-Blanks) in column D to only get the results you're interested in.

Extract list in excel based on criteria

I have a list of names and a list of categories in a table.
Example:
Name Category 1 Category 2 Category 3
Jane Doe X X
Bill Smith X X
Eric Hamilton X
From that list, I want to list the people for each category.
Example:
Category 1 Category 2 Category 3
Jane Doe Jane Doe Bill Smith
Bill Smith Eric Hamilton
Is there a way I can do this in excel?
I found this video which seems to accomplish what I want. The formula is a bit more complicated than what I was hoping for, but it worked. I just removed some of the absolute cell references and copied the formula for the number of categories I currently have and it grouped the users properly.
https://www.youtube.com/watch?v=QkHfZtvC7UQ

Excel countif or if

Tried doing this a few ways and I think I'm just looking at this a little too complicated.
I have column a with several different names that repeat. I have column B with dollar amounts. I'm trying to get a formula that will add the totals amount for a specific person.
JOHN $17.23
JAMES $37.52
JOHN $14.23
JAMES $27.52
APRIL $32.00
APRIL $143.20
JOHN $90.27
JOHN $81.13
JOHN = Total for John
JAMES = Total for James
APRIL = Total for April
Thank you
Assuming this table
A B
1 Names Bill
2 John 10
3 Tom 20
4 John 4
5 Tom 3
To get the total for each name you can write
A B
7 Names Total
8 John =Sumif(A2:A5;A8;B2:B5)
9 Tom =Sumif(A2:A5;A9;B2:B5)
This will sum up each value for the given area.
Consider:
=SUMPRODUCT((A$1:A$8="John")*(B$1:B$8))
=SUMPRODUCT((A$1:A$8="James")*(B$1:B$8))
=SUMPRODUCT((A$1:A$8="April")*(B$1:B$8))
Striking my original response in favor of:
=SUMIF(B3:B10,"=JOHN",C3:C10) I tested that, and it works even better

Excel - Counting unique records in a group

I'm having difficulty counting records in a file that have a unique ID and listing the number of rows associated with that specific ID.
For this file, the unique ID represents a specific family (column A). Each member of the family is in a different row with the same ID. I would like to count the number of family members(rows) in each unique family. I can have a few thousand rows so automating this would be wonderful. Thanks for any help!!
You can do this now automatically with Excel 2013.
If you have that version, then select your data to create a pivot table, and when you create your table, make sure the option 'Add this data to the Data Model' tickbox is check (see below).
Then, when your pivot table opens, create your rows, columns and values normally. Then click the field you want to calculate the distinct count of and edit the Field Value Settings:
Finally, scroll down to the very last option and choose 'Distinct Count.'
This should update your pivot table values to show the data you're looking for.
So if I'm understanding you correctly, you have something like
A B C
Fam. ID LastName FirstName
1 Smith John
1 Smith Mary
1 Smith Johnnie Jr
2 Roe Rick
3 Doe Jane
3 Doe Sam
and you want a new column (say, D), with a count of members per family:
A B C D
Fam. ID LastName FirstName Fam. Cnt
1 Smith John 3
1 Smith Mary 3
1 Smith Johnnie Jr 3
2 Roe Rick 1
3 Doe Jane 2
3 Doe Sam 2
This will do it -- insert at D2 and drag down:
=COUNTIF(A:A,A2)

Resources