tabulate total usage by month in a year - calculated-columns

i would like to list the total consumption used by month for a customer table
Date Reading
------- ----------
02-dec-11 750
03-jan-12 1000
05-feb-12 1250
.
.
.
05-dec-12 2300
Expected results
Month Total
------- ---------
JAN 250 (1000-750)
FEB 250 (1250-1000)
.
.
.

Related

Use PIVOT TABLE to show occupation percentage by month from date ranges. google sheet

my first time here.
I have a lease table where each row has the follow:
Lease number | Tenant name | unit number | checkin date | checkout date.
I need to have a table (prefer a PIVOT) that will show me the total occupation (by %) per month for each year. Keep in mind that the checkin-checkout dates can be from mid of one month till mid of another month (oct 3 2020 - feb 17 2021)
Expected result:
| 2019 | 2020 | 2021
jan | 0% | 58% | 67%
feb | 67% | 21% | 42%
mar ....
as I'm not a professional sim looking for a simple/easy way to resolve it.

How to dynamically calculate the overtime left and the overtime used without a circular reference in Excel?

The goal is to fix a circular reference in my logic in this "two weeks pay" input workbook.
It's a temporary sheet for when people are outside the office and can't access the system.
That said, that sheet still should give them accurate data.
There's 26 sheets that contains the times done by an employee for example, in a typical format, for 2 weeks in each (a year in total).
Stripped of all formatting and non-useful information for this enquiry, they would look somewhat like this (with proper dates) :
+-----------+----------+--------+----------+--------+-------+------+
| Date | AM start | AM end | PM start | PM end | total | over |
+-----------+----------+--------+----------+--------+-------+------+
| Monday | 8:00 | 12:00 | 13:00 | 16:00 | 7:00 | 0:00 |
+-----------+----------+--------+----------+--------+-------+------+
| Tuesday | 8:00 | 12:00 | 13:00 | 15:00 | 6:00 | 0:00 |
+-----------+----------+--------+----------+--------+-------+------+
| Wednesday | 8:00 | 12:00 | 13:00 | 17:00 | 8:00 | 1:00 |
+-----------+----------+--------+----------+--------+-------+------+
| ... | .... | .... | .... | .... | .... | .... |
+-----------+----------+--------+----------+--------+-------+------+
Then on another sheet, there's some calculation has to what is the paid amount (maximum 70 hours per 2 weeks), the overtime done that has to be paid, etc.
A B C D E F G
+-------+------------+----------+---------------+-----------------------+-------+---------------------+
1 | Pay # | Hours paid | Overtime | Used overtime | Total hours worked | | Total overtime left |
+-------+------------+----------+---------------+-----------------------+-------+---------------------+
2 | 1 | 70:00 | 5:00 | 0:00 | 75:00 | | 0:00 |
+-------+------------+----------+---------------+-----------------------+-------+---------------------+
3 | 2 | 70:00 | 0:00 | 5:00 | 65:00 | | |
+-------+------------+----------+---------------+-----------------------+-------+---------------------+
4 | ... | ... | ... | .... | | | |
+-------+------------+----------+---------------+-----------------------+-------+---------------------+
In the above table, the pay #2 got 70 hours paid, but the person would have done only 65 hours and used 5 hours of the overtime done the past two weeks.
A1:E4 is connected together, G1:G2 is data by itself, not linked to the pay numbers or other data in that sheet (in other words, there is only one cell that contains that total overtime left and F is used to separate both tables).
G2 currently have 0:00 because the 5:00 it would have had has been used to complete the second pay.
The Hours paid cell (B) contains this formula :
=IF($E$2>=2.91666666666667,2.91666666666667,IF((2.91666666666667- $E$2)<=$G$2;2.91666666666667,$E$2+$D$2))
Step 1 [condition] : If the total hours worked for that two weeks is greater than or equals to 70 hours (the 2.91666666666667 is used here instead of "70:00" to make the comparison works);
Step 1.1 [true] : Then put "70:00" in the cell because there's a 70 hours maximum per two weeks (this is fine since we have another cell that stores the overtime done (in this example, C));
Step 1.2 [false->condition] : Else, the total hours worked for that two weeks is lower than 70 hours so check if 70 hours minus the total hours worked for that two weeks is lower than the total overtime left to be used (used to check if there's overtime left that can be used this time to make the pay the highest it can be up to a maximum of 70 hours);
Step 1.2.1 [true] : If it is, put 70 hours because we'll use some of the overtime left to be paid to complete this two weeks;
Step 1.2.2 [false] : Otherwise, put the total hours worked for that two weeks added to the used overtime for that week (this cell is explained later with her formula and this step is for when there's overtime left, but not enough to make it go up to 70 hours so we put the amount of time it ends up being).
The important part here is to remember that B needs D, hence why I explained it's formula.
The Overtime (C) and "Total hours worked" (E) cells contains basic formulas that either gives the amount of time over 70 hours or the total hours worked; no need to explain it here, it works.
The Used overtime cell (D) is where it gets tricky. To explain it, we'll need to know what's up with G2.
The Total overtime left cell (G2) is the total of overtime hours minus the sum of all cells in D (used overtime).
It's purpose is to get an up to date value of how much overtime there is left to be paid.
Back to Used Overtime.
You probably start to see circular reference here; D needs G2 to work and G2 is the sum of all cells in D (in the table range, not all of them).
The formula requires the notion of how much overtime there is left so it can check if we can use some.
Here's the formula :
=IF($E$2>=2.91666666666667,"00:00",IF((2.91666666666667-$E$2)<=$G$2,(2.91666666666667-$E$2),IF(($G$2+$E$2)<=2.91666666666667,$G$2,"00:00")))
Step 1 [condition] : If the total hours worked for that two weeks is greater than or equals to 70 hours;
Step 1.1 [true] : Then put 0 hours since that pay is already at the 70 hours maximum;
Step 1.2 [false->condition] : Else, the total hours worked for that two weeks is lower than 70 hours and could grow higher if we still have overtime to be paid so check if 70 hours minus the total hours worked for that two weeks (the amount of time we could add from the overtime left) is lower than or equals to the total overtime left to be paid;
Step 1.2.1 [true] : Then put 70 hours minus the total of hours worked for that two weeks (the amount of time we will add from the overtime left to make this pay grows to the maximum of 70 hours);
Step 1.2.2 [false->condition] : Otherwise, check if the total overtime left added to the total of hours worked for that two weeks is lower than or equals to 70 hours (if so, then it means that we can add all the overtime left here without getting over 70 hours);
Step 1.2.2.1 [true] : If it is then the value is the total overtime left since it will make the total hours worked for that two weeks still be under the maximum yet pay for the overtime that was left to be paid;
Step 1.2.2.2 [false] : Otherwise, put 0 hours since we will not be adding overtime to this pay because there is no overtime left to be added.
How could I both have the accurate overtime left and yet have the used overtime both dynamically calculating themselves without a circular reference ?
What if every row had an up to date value for Total Overtime Left after that pay period?
Formula for G2: =C2-D2
Then every G cell after that only needs to add the Overtime Left from the previous pay period + overtime - used overtime:
G3: =G2+C3-D3
And it just goes on from there.

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

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.

Pivot table calculate field based on grouped values

after years of quietly learning from this site I've finally hit a question who's answer I cannot seem to find on StackOverflow...
I have a pivot table that needs to calculate Net Promoter Score from several groups within a population.
Net promoter score is calculated like so:
[% of Population that give 9 or 10/10] - [% of Population that give 1 to 6/10]
Each individual record in my source data can only have a single Score of between 1 and 10:
RAW DATA:
Date (dd/mm) Country Type Score (1-10) NPS Category
01/05 US Order enq. 9 Promoter
13/05 US Check-out 5 Detractor
28/05 US Order enq. 7 Passive
So, with help from the answers below I've added a column to categorise each individual into the Promoter (9 or 10), Passive (7 or 8) and Detractor (1 to 6) groups based on that score: screenshot of raw data (with sensitive items hidden).
All that remains now is:
How can I create a calculated 'NPS' column like the one shown in my (rudimentary) representation of a pivot table below that takes the Detractor value from the Promoter value?
D = Detractor group
Pa = Passive group
Pr = Promoter group
| Order enquiry | Check-out |
| D Pa Pr NPS | D Pa Pr NPS |
-------------------------------------------------- |
GB | | |
May | 0 0 100 100 | 30 20 50 20 |
Jun | 10 30 60 50 | 35 35 60 25 |
Jul | 30 20 50 20 | 40 10 40 0 |
US | | |
May | 45 15 40 - 5 | 50 10 40 -10 |
Jun | 40 30 30 -10 | 40 30 30 -10 |
Jul | 5 35 60 55 | 20 40 40 20 |
My attempt at a calculated column can be seen in this screenshot. This results in an error and of course I haven't managed to convert the NPS counts into percentages yet.
It would be my suggestion to create a new column in the source that calculates D, Pa,Pr by a formula.
You can now create the % for these values in the pivot. The NPS column can either be calculated after pivoting the output field, or by creating a pivot-column formula in Excel.
It's not clear from your question how your data is laid out, or what exactly you're asking. From what I can see, you need to add a column in your raw data table, which says something like
=COUNTIFS(UniqueID,MyUniqueID,Score,">=9")-COUNTIFS(UniqueID,MyUniqueID,Score,"<=6")
Then another column that says
=IF(NetPromoter>=9,"Pr",IF(NetPromoter>=7,"Pa","D"))
And then in your pivot table you add the Classification as a new subcolumn, and add the NPS as the Average of your NPS column, or something like that.
Please show your data if you want the formulas changed to meet your actual range/variable terms.

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