Excel Pivot Table: How do I count the number of working days for employees based on date-time values? - excel

In my theoretical data set, I have a list which shows the date-time of a sale, and the employee who completed the transaction.
I know how to do grouping in order to show how many sales each employee has per day, but I'm wondering if there's a way to count how many grouped days have more than 0 sales.
For example, here's the original data set:
Employee | Order Time
A | 8/12 8:00
B | 8/12 9:00
A | 8/12 10:00
A | 8/12 14:00
B | 8/13 10:00
B | 8/13 11:00
A | 8/13 15:00
A | 8/14 12:00
Here's the pivot table that I have created:
Employee | 8/12 | 8/13 | 8/14
A | 3 | 1 | 1
B | 1 | 2 | 0
And here's what I want to know:
Employee | Working Days
A | 3
B | 2

Split your Order Time column (assumed to be B) into two, say with Text to Columns and Space as the delimiter (might need a little adjustment). Then pivot (using the Data Model) as shown:
and sum the results (outside the PT) such as with:
=SUM(F3:H3)
copied down to suit.
Columns F:G may then be hidden.
I fully support #Andrea's Comment (a correction) on the above:
I think this could have been made simpler. If you remove the "Time" in values of the pivot table and then move "Order" from columns to values and use distinct count as in the example. It should count Employee per date making the sum not needed. If you scale this to make it larger. Say 50 dates then the =Sum() needs to be moved each time.

Related

Customizing Weekday/Workday Function to reflect actual working hours

So my company services clients with insurance products and we have two teams: Liability and Crime. There are generally one 4 different types of task: Binding, Issuance, Quoting and Rapids.
I currently have made a spreadsheet based on data obtained through our workflow.
The main formulas I use to calculate service due date for Crime/Liability team is:
=IF(OR(WEEKDAY(IF(A2="Binding",C2+(1/8),IF(A2="Quoting",C2+(1/8),IF(A2="Issuance",C2+2,IF(A2="Rapids",C2+(1/8),"")))))=1,WEEKDAY(IF(A2="Binding",C2+(1/8),IF(A2="Quoting",C2+(1/8),IF(A2="Issuance",C2+2,IF(A2="Rapids",C2+(1/8),"")))))=7,IF(A2="Binding",C2+(1/8),IF(A2="Quoting",C2+(1/8),IF(A2="Issuance",C2+2,IF(A2="Rapids",C2+(1/8),"")))))+2,IF(A2="Binding",C2+(1/8),IF(A2="Quoting",C2+(1/8),IF(A2="Issuance",C2+2,IF(A2="Rapids",C2+(1/8),"")))))
Where you have 3 hours to finish binding, quoting, rapids, and you have two days for issuance.
We are now expanding our service to California, which is three hours behind EST time, so now comes the issue: We want to expand our working hours (est time) to 9 am - 8 pm to cover west coast. But, does is it possible to tell excel to do that via a weekday/workday function?
The goal is to have the due dates wrap around weekends to Monday and anything after 8 pm (est time) to being due next day.
For example: If a binding task comes in at 7:00 pm, then you would have 1 hour till 8 pm, and so the task would be due at 11:00 am the next day. Is this even possible to do with just excel? Any help would be immensely appreciated guys, thank you!
Your formula can be simplified greatly if you have a lookup table in your workbook somewhere that returns the due time values. For the example below, my lookup table is in Sheet2, A1:
Sheet 1 - Example Data
| A | ... | C | D |
+--------+ ... +-----------------+----------------+
1 | Task | | Received | Due |
2 |Binding | |19/02/2018 09:00 |19/02/2018 12:00|
3 |Quoting | |19/02/2018 13:00 |19/02/2018 15:00|
Sheet 2 - Lookup table:
| A | B |
+--------+-------+
1 |Binding | 0.125 |
2 |Quoting | 0.125 |
3 |Issuance| 2 |
4 |Rapids | 0.125 |
Formula
The formula in Sheet1 D2 is:
=C2+INDEX(Sheet2!B:B,MATCH(Sheet1!A2,Sheet2!A:A,0))
From there it should be a lot simpler to construct an IF STATEMENT to rollover to the next day if the order is received past 5pm (would be due after 8pm).

Sum only values which fall Monday to Friday

I receive a statement (as a .xls) each month which list a bunch billable items with an associated date. I want to create a formula (using either =sum() or =sumifs() to total the billable items, but only those which fall Monday to Friday (i.e., not weekends). Is that possible?
A B
------+--------------+-------------
1 | 05/12/2016 | $10.00
2 | 06/12/2016 | $10.00
3 | 07/12/2016 | $10.00
4 | 08/12/2016 | $10.00 dates are formatted as
5 | 09/12/2016 | $10.00 dd/mm/yyyy
6 | 10/12/2016 | $10.00
7 | 11/12/2016 | $10.00
8 | 12/12/2016 | $10.00
------+--------------+-------------
| Sum | $80.00
------+--------------+-------------
| Sum |
| (no weekends)| $60.00
------+--------------+-------------
EDIT:
I've just looked closer at the excel doc, and it's actually a datetime field, e.g. 31/10/2016 12:44:00 pm (displayed as 31/10/16 12:44).
I'm also not looking for a formula which works line by line, I'd like something which I can just copy and paste into a single cell at the bottom of the doc each month which examines A:A.
You need to use this formula:
=SUMPRODUCT(B1:B8,--(WEEKDAY(A1:A8,2)<6))
This is a hack which behaves like SUMIF but lets you use a function in your criteria. Otherwise, you would need to create an auxiliary column with WEEKDAY (in C for example) and then use =SUMIF(C1:C8,"<6",B1:B8).
WEEKDAY by default returns 1-7 for SUN-SAT. As this doesn't help, you can change the return type to type 2 with the optional second parameter to make the function return 1-7 for MON-SUN, which lets you do the easy <6 comparison. You can also use type 3, which returns 0-6 for MON-SUN, and then obviously use <5 instead.
More about the -- hack here.

Obtain average based on multiple criteria from table column

I have a table that more or less looks like this:
Team_Name | Total_Errors | Total_Volume
_______________________________________
Sam | 3 | 1350
Sam | 5 | 1100
Jamie | 7 | 1600
Mark | 3 | 1220
Jamie | 10 | 2100
Mark | 5 | 1300
Sam | 5 | 1100
Jamie | 3 | 1900
Just with a lot more rows. I want to create a formula that calculates the average total_errors for just the numbers corresponsding to Team_names "Jamie" and "Sam".
How do I do this?
Something like Average(If(June(Team_Name)="Jamie","Sam"......?
(the table name is June)
thanks in advance
You can use Sum/Count:
=(SUMIF(A1:A8,"Jamie",B1:B8)+SUMIF(A1:A8,"Sam",B1:B8))/(COUNTIF(A1:A8,"Jamie")+COUNTIF(A1:A8,"Sam"))
I would go with a simple pivot table that uses June as a data source.
Put your Team_Name filed as a rows, and Total_Errors as Values. Change the Field settings of your Total_Errors to be an average, and change how many decimal points you want to see.
You can then apply whatever filters /Slicers you want and get your desired result.
Here's a screenshot (its on MAC, but you'll get the idea)
Assuming DATA in located at A1:C9 enter this formula at F5, note tat the Criteria Range used by the formula is locaed at E2:E4 (see picture below):
=DAVERAGE($A$1:$C$9,$B$1,$E$2:$E$4)

Is it possible to merge two tables into one and create a pivot table from both datasets

Slightly awkward requirements, so I apologise if the explanation isn't overly clear.
I have two tables, with very similar data (though not identical), which I'd like to merge together and total up as follows.
Both Tables Contain the following headings
Invoice, Date, Account, No., Description, Blank, Credit, Debit, Total
However, they are for slightly different things (support and commission to be exact). Both tables contain multiple rows of data for various customers, but some customers may only be in one table or the other.
I've used pivot tables for each table individually to show the sum totals for each customer (so I have a table of every customers total support value, and a separate table for every customers total commission). Similarly to above though, customers may be in one pivot table but not the other.
What I would like is a single table to show every customer from both tables (if they are in both tables, I only want one record), with the total support (showing 0 if the customer isn't in the table), the total commission (again, 0 if the customer isn't is that table), and ideally the total overall (although this is a simple sum of the other two, so can be added in after if required...
As an example, if the relevant columns in two tables were;
Support Commission
Account | Total Account | Total
----------------- -----------------
A | 25.00 A | 5.00
A | 25.00 C | -10.00
A | 45.00 C | 10.00
B | 10.00 C | 30.00
B | -5.00 C | 25.00
C | 5.00 D | 25.00
C | 10.00 D | -5.00
C | 10.00 E | 15.00
E | 25.00
I'm trying to end up with a table that looks like;
Account | Support Total | Commission Total | Overall Total
----------------------------------------------------------------
A | 95.00 | 5.00 | 100.00
B | 5.00 | 0.00 | 5.00
C | 25.00 | 55.00 | 80.00
D | 0.00 | 20.00 | 20.00
E | 25.00 | 15.00 | 50.00
This isn't something I'd want to do manually, as my actual tables have 2000+ rows in them.
Any help would be greatly appreciated. (I've been messing around with various Excel features for a long time now and I've run out of ideas)
Use multiple consolidation ranges (e.g. further details here - but you can stop short of creating the Table).
Ensure your separate sources have the same column labels:
N.B. 25+15 = 40 :)

Excel to calculate capacity levels

I have a table in excel setup as followed:
DATE | TIME | PERSON IDENTIFIER | ARRIVAL OR LEAVING
01/01/15 | 13:00 | AB1234 | A
01/01/15 | 13:01 | AC1234 | A
01/01/15 | 13:03 | AD1234 | A
01/01/15 | 13:05 | AE1234 | A
01/01/15 | 13:09 | AF1234 | A
01/01/15 | 13:10 | AB1234 | L
01/01/15 | 13:15 | AG1234 | A
01/01/15 | 13:13 | AC1234 | L
The table shows when people arrive and leave a medical ward. The ward holds 36 patients and I'm wanting to get an idea of how close it is to capacity (it's normally always full). The ward is open 24/7 and has patients arriving 24/7 but I'd like to show the time it is at the certain capacities.
For example if we inputted 24 hours of data
36 patients (0 empty beds) - 22hr 15min
35 patients (1 empty bed) - 01hr 30min
34 patients (2 empty beds) - 00hr 15min
I'm thinking we just need a count for every time some arrives and a negative count when they leave but I can't figure out how to extract the time from that.
This is going to be pretty ugly (NB using your columns from above):
order the entries sequentially
you can keep a running tally in column E of patients on hand currently with E1 = 36(or whatever starting value you have) and =IF(D2="A",E1+1,E1-1).
Get the time elapsed since the previous entry with =(B3-B2) and put that in column F
Count the chunks where you had less than a full house with =SUMIF(F:F, "<36")

Resources