Count Unique Entries in a Month for Pivot Table - excel

Good afternoon,
I'm currently working on setting up a pivot table for chart that outlines an Average Revenue per Person by Line Type. Using the pivot table, I can sort everything out, but when I try to get a count of person, it adds all instances of that person's name up. What I want is that if the person's name appears once in a month, all other instances in that month of the person's name are not counted. But during a new month, the person's name will appear once more. So, it is somewhat like a unique count, but only unique per month.
My excel table looks something like:
A B C D
Date Person Revenue Line Type
1/1/2015 John $100 Toy
1/6/2015 Phil $200 Toy
1/6/2015 Jane $25 Garden
1/7/2015 John $50 Electronics
1/25/2015 John $10 Electronics
2/1/2015 John $10 Toy
2/17/2015 Phil $30 Garden
2/20/2015 Bob $500 Electronics
2/21/2015 Jane $100 Garden
So, as you can see, a person's name can occur more than one time in a month, and in more than one month. Currently, the code I am using for my helper column (E) is:
=1/COUNTIF($B:$B,B2)
This has only been giving me a count of patients throughout the entire year, not taking new months into account. I also have attempted this formula:
=IF(SUMPRODUCT(($B$2:$B2=B2)*($A$2:$A2=A2))>1,0,1
This only counts values that occur on the same day. I've tried adding in MONTH() checks and such, and am only getting syntax errors. I'm not sure where to turn for this one. Thank you!

Thanks to #TomSharpe's advice, I added a helper column to concatenate Month/Date and the Patient's name like so:
=MONTH(A2)&"-"&B2
Then used the original formula (below) to COUNTIF divided by 1.
=1/COUNTIF($B:$B,B2)
This gave me exactly what I needed.
Thanks again!

Related

Excel Retention Calculation

Excel Masters,
I have an Excel worksheet with a list of employees (ColumnA), dates (ColumnB), and Customers(ColumnC). I want to calculate the employees retention rate based on the customers that visited.
If a customer visited an employee and came back the next month and visited the same employee, they are considered retained for that employee.
If a customer visited an employee and came back the next month and visited a different employee, they are considered retained.
If a customer visited in one month, but didn’t come back the next month, they are considered lost.
Employee Date Customer
Zach 11/2/19 Tyler
Zach 11/20/19 Tyler
Zach 10/2/19 Tiffany
Zach 10/3/19 Tiffany
George 11/1/19 Tiffany
George 11/9/19 Tyler
George 10/2/19 Mike
George 10/30/19 Michael
I want to see a % retention for each employee across all months that are in the data.
At the moment, I've tried using a combination of COUNTIFS to find the solution but with no luck.
I can offer an in-place calculation, but it can also be converted to a separate report.
Formula for 'Retained' calculation:
=--(SUMPRODUCT(--(C2=$C$2:$C$11);(--(MONTH(B2)+1=MONTH($B$2:$B$11)))+(--(MONTH(B2)-1=MONTH($B$2:$B$11))))>0)
Array formula for 'Retention %' calculation (for employee across all clients):
{=SUM(IF(A2=$A$2:$A$11; IFERROR(1/(COUNTIFS($A$2:$A$11; A2; $C$2:$C$11; $C$2:$C$11;$D$2:$D$11;1));0); 0))/SUMPRODUCT(1/COUNTIF($C$2:$C$11;$C$2:$C$11))}
Edit:
Just add example with an percentage report in a separate table. Same formula, just moved to new area:
{=SUM(IF(G2=$A$2:$A$11; IFERROR(1/(COUNTIFS($A$2:$A$11; G2; $C$2:$C$11; $C$2:$C$11;$D$2:$D$11;1));0); 0))/SUMPRODUCT(1/COUNTIF($C$2:$C$11;$C$2:$C$11))}

How can I determine how much time a customer has spent speaking to multiple agents

I have a spreadsheet in which each records the amount of time a customer spent on the phone with an agent, I want to write a formula that averages the total time spent by a user per agent.
Customer Agent Time spent (MM:SS)
John Smith Sally Jenkins 1:15
John Smith Sally Jenkins 2:07
John Smith Adam Apple 3:55
John Smith Adam Apple 1:42
For example, how can I determine the average time John Smith Sent with Sally Jenkins, output that, and then separately determine the average time John Smith spent with Adam apple?
Is that even possible? Any help would appreciated. Thank you!
The simplest way is probably to use a Pivot Table. Insert a Pivot Table based on your data, then put Agent in the Rows, and Average of Time Spent in the values.
You can also use SumIfs()/CountIfs to get an average over a large dataset given specific criteria without needing to manually select the cells with the times to average. With this, you can select the entire data range and the formula will figure out which cells to include in the average based on the criteria you specify.
=SUMIFS($C$2:$C$5,$A$2:$A$5,F2,$B$2:$B$5,G2)/COUNTIFS($A$2:$A$5,F2,$B$2:$B$5,G2)
I don't know of anything simpler than AVERAGEIF/AVERAGEIFS.
In G2 per image (and filled down),
=AVERAGEIFS(C:C, A:A, E2, B:B, F2)
In G6 per image,
=AVERAGEIFS(C:C, A:A, E6)
If your cells are formatted properly, you can just use =AVERAGE():

Sum product for all the months if 2 tables match

So I have this issue, I have two tables one is employees, and another one is the projects.
Employees Table:
Year Name Type Jan Feb
2018 Kevin Salary 5000 2000
2018 Kevin Insurance 200 400
2018 Alex Salary 3000 4000
2018 Alex Insurance 300 400
Projects Table
Year Project_Name Employee_Name Jan_Hours_Worked Feb_Hours_Worked
2018 Apple Alex 7 5
2018 Apple Kevin 5 0
2018 LG Kevin 0 3
Now I am creating a result list of all the projects and costs recurred for them, what I need is for each project in Table 2 to find which employees are involved and then use that to find related costs for the employee from the Table 1 and calculate total costs for that project.
(e.g for project LG, I have Kevin working on that in Feb,for him company paid 4400(salary+insurance) in Feb and the costs recurred for the LG project would be 4400 divided by hours spent on the project which Kevin in total spent 3 hours; e.g.2 for the project Apple it would be the same but sum of Kevin's and Alex's costs from Jan and Feb, so Kevin: 5200/5 + Alex:3300/7 + 4400/5)
Now I have the formula to calculate this for 1 months which is something like this
=SUMPRODUCT(SUMIFS(Employees[Jan], Employees[Name],Project[Employee_Name], Employees[Year], 2018 )/Project[Jan_Hours_Worked],--(Project[Project_Name]=K14))
I need to find how to get the yearly result per project without repeating the formula 12 times, also with this formula, i get div to 0 error when an employee didn't work on particular months, so that needs to be sorted somehow. Any Help?
I suggest you to change how you store your data. If you can make some minor changes, then you can have an easy way to get the information you want, and also a Pivot Table with a summary of cost recurred for each proyect and which employee generated that cost.
IMPORTANT: For this answer to work, you must make sure that every Employee's Name is UNIQUE. If not, adapt the example trying to create
an Employee's ID or something.
Also, please, note i got a spanish version of Excel, so screenshots are in spanish but I will translate formulas :)
Ok, first of all, I changed the design of your table Employees. Creating a column for each month is kind of annoying. Use just a column to get the month. You can type the month in a cell just like 01/2018 and Excel will change it instantly to format mmm-yy (Jan-18)
This is how your Employees table should look:
The column TOTAL COST is just a sum of SALARY + INSURANCE. If you have any other concept, just add it as a column and modify the TOTAL COST COLUMN to include it.
Second, the table Project, I think it should be like this:
The column Employee Cost has an Array Formula.
IMPORTANT: Array formulas are inserted pressing CTRL+SHIFT+ENTER
The formula is (I used same names for tables, so copy-pasting should work for you):
=INDEX(Employees;MATCH(Project[[#This row];[Employee_Name]]&Project[[#This row];[Month]];Employees[Name]&Employees[Month];0);COLUMN(Employees[[#Headers];[TOTAL COST]]))
If you typed the formula right, you should see { at start and } at end.
The formula in Cost Recurred to Project is just a division of Employee Cost / Hours. Added an IFERROR when the hours worked are 0, then show 0.
=IFERROR(Project[[#This row];[Employee Cost]]/Project[[#This row];[Hours]];0)
And last step, your Pivot Table. Create one and organise it to get the sum per hours and month and proyect you want. You can get one like the one below:
As you can see,e.g. for project Apple, you can see that total cost is 2.391,43
but also you can see the cost of each Employee. Pretty cool I think.
I really hope you can modify the design of your data, because Excel is designed to work going down (I mean using rows) more than using columns. Excel 2007 got more than 1 million of rows and just around 16.000 columns, so it's designed to work vertically.
Hope this helps, or at least, give to you a clue of how to proceed :)

Lookup with multiple criteria, one a MAX value

I am trying to lookup the LOCATION of an employee (NAME) and their MANAGER from the most recent month (largest month number) in a particular QUARTER in data like this:
NAME LOCATION MANAGER QUARTER MONTH
Ryan Smith Sioux Falls Rick James 3 7
Jane Doe Tampa Bobby Brown 3 7
John Rogers Tampa Tracy Lane 3 7
Ryan Smith Sioux Falls Rick James 3 8
Jane Doe Denver Thomas Craig 3 8
John Rogers Tampa Cody Davis 3 8
So if I know the name of the employee and the quarter I'm looking up, the results should display who their last manager was and the location they were in, as these may change month to month.
I have used an INDEX and MATCH array formula:
{=INDEX($B$2:$B$7,MATCH(A12,IF($D$2:$D$7=D12,$A$2:$A$7),0))}
but this just provides the first match and not necessarily the most recent month in that quarter. I attempted to include a MAX function which looked something like this:
{=INDEX($B$2:$B$7,MAX($E2:$E7,MATCH(A12,IF($D$2:$D$7=D12,$A$2:$A$7),0)))}
but that didn't quite get me there either.
What formula do I need to get this to work?
I think I'd choose a PivotTable for its versatility and speed:
I think a pivot table is probably the best option and can easily be modified with the filters when new entries are added to the underlying data. I was working on a solution with a formula, but it requires you to add a lookup column.
The formula for the lookup column is: =E6&" "&H6&" "&I6
I wasn't clear on how the OP was going to be "entering" his employee name and quarter, so I had to make an assumption that it would be in a separate column:
And the formula in column B (which is cumbersome) is:
=VLOOKUP(A6&" "&MAX(IF(H1:H100=NUMBERVALUE(RIGHT(A6,1)),I1:I100)),$D$6:$G$11,3,FALSE)&", managed by "&VLOOKUP(A6&" "&MAX(IF(H1:H100=NUMBERVALUE(RIGHT(A6,1)),I1:I100)),$D$6:$G$11,4,FALSE)
But it works, and as long as the lookup range is adjusted, is scaleable.

Excel Vertical and Horizontal view of cells

I am trying to create a booking system using Excel. I know this may not be the best option, however so far this is what I have come up with:
sheet1 with all customer details
sheet2 with all booking details
The customer id and name are ref to sheet2 so I don't have to type them again.
On sheet2 I have the customer name in column A and in Column B dates for different days laid out horizontally.
For example:
Customer Name Course 1 Course2 Course3
John Smith 01.01.2014 02.01.2014 03.01.2014
Bob Green 02.01.2014 03.01.2014 04.01.2014
The problem I am having at the moment is not being able to identify all customers who are booked on same date. For example if I want to see all the customers who are booked for 01.01.2014, how is that possible?
Any help will be great, or if you have better ideas about creating a booking systems suggestions are welcome.
You need to change your layout, then you can apply a filter. A better layout would be:
Customer Name Course Name Date
John Smith Course 1 01.01.2014
John Smith Course 2 02.01.2014
John Smith Course 3 03.01.2014
Bob Green Course 1 02.01.2014
Bob Green Course 2 03.01.2014
Bob Green Course 3 04.01.2014
Then just apply a filter on the Date column. To see all people in the same course and on the same date, apply a filter to both the Course Name and Date columns.

Resources