I am trying to create a pivot table that displays the number of projects ongoing per month. I have start and end dates for the project, the project number, and the employee responsible for the project. I would like to delineate the pivot table by month, showing the total number of projects, and then being able to drop that down even further with the projects in that month. I have low experience with pivot tables so I appreciate any help.
Here is a table of the data.
+---------+----------+------------+------------+
| Project | Employee | Start Date | End Date |
+---------+----------+------------+------------+
| BT 1 | Jack | 9/16/2019 | 12/13/2019 |
| BT 2 | Jack | 9/22/2019 | 12/20/2019 |
| BT 3 | Jack | 9/23/2019 | 12/20/2019 |
| BT 4 | Jack | 9/29/2019 | 12/20/2019 |
| BT 5 | Jack | 9/23/2019 | 1/9/2020 |
| BT 6 | Jack | 9/16/2019 | 1/10/2020 |
| BT 7 | Jane | 9/30/2019 | 12/13/2019 |
| BT 8 | Jack | 10/3/2019 | 1/24/2020 |
| BT 9 | Jane | 10/7/2019 | 1/17/2020 |
| BT 10 | Jane | 11/4/2019 | 3/13/2020 |
| BT 11 | Jim | 11/12/2019 | 3/20/2020 |
| BT 12 | Jim | 12/1/2019 | 2/20/2020 |
| BT 13 | Jane | 12/2/2019 | 3/4/2020 |
| BT 14 | Jim | 12/2/2019 | 3/27/2020 |
| BT 15 | Jim | 12/9/2019 | 4/3/2020 |
| BT 16 | Jack | 1/5/2020 | 2/27/2020 |
| BT 17 | Jim | 12/16/2019 | 4/17/2020 |
| BT 18 | Jack | 1/2/2020 | 3/25/2020 |
| BT 19 | Jack | 1/12/2020 | 3/27/2020 |
| BT 20 | Jack | 12/15/2019 | 4/2/2020 |
| BT 21 | Jack | 1/6/2020 | 4/10/2020 |
| BT 22 | Jack | 1/6/2020 | 4/10/2020 |
| BT 23 | Jack | 1/13/2020 | 4/10/2020 |
| BT 24 | Jack | 1/13/2020 | 4/24/2020 |
| BT 25 | Shane | 1/19/2020 | 3/20/2020 |
| BT 26 | Jack | 2/3/2020 | 5/8/2020 |
| BT 27 | Jack | 2/24/2020 | 5/15/2020 |
| BT 28 | Jack | 2/17/2020 | 5/22/2020 |
| BT 29 | Jack | 4/13/2020 | 5/22/2020 |
| BT 30 | Jack | 2/9/2020 | 5/29/2020 |
| BT 31 | Jack | 2/17/2020 | 5/29/2020 |
| BT 32 | Jack | 4/19/2020 | 5/29/2020 |
| BT 33 | Jack | 3/16/2020 | 6/5/2020 |
| BT 34 | Jack | 3/1/2020 | 6/18/2020 |
| BT 35 | Jack | 4/13/2020 | 7/10/2020 |
| BT 36 | Jack | 4/13/2020 | 7/10/2020 |
| BT 37 | Jack | 6/8/2020 | 7/24/2020 |
| BT 38 | Jack | 3/30/2020 | 7/31/2020 |
| BT 39 | Jack | 4/13/2020 | 8/7/2020 |
| BT 40 | Jack | 4/20/2020 | 8/7/2020 |
| BT 41 | Jack | 5/11/2020 | 8/7/2020 |
| BT 42 | Jack | 7/5/2020 | 9/30/2020 |
| BT 43 | Jack | 7/12/2020 | 9/30/2020 |
| BT 44 | Jack | 6/8/2020 | 10/2/2020 |
| BT 45 | Jack | 7/13/2020 | 10/2/2020 |
| BT 46 | Jack | 7/6/2020 | 10/9/2020 |
| BT 47 | Jack | 6/14/2020 | 10/22/2020 |
| BT 48 | Jack | 7/6/2020 | 10/23/2020 |
| BT 49 | Jack | 8/3/2020 | 10/30/2020 |
| BT 50 | Jack | 7/13/2020 | 11/13/2020 |
| BT 51 | Jack | 7/27/2020 | 11/13/2020 |
| BT 52 | Jack | 9/14/2020 | 12/11/2020 |
| BT 53 | Jack | 11/2/2020 | 2/19/2021 |
+---------+----------+------------+------------+
Thanks.
Related
Excel
| A | B | C | D | E | F | G | H |
---|-----------------|----------|--------|--------|-----------|-------------|---------|----------|---
1 | Loan | 50.000 | Year | Start | Interests | Repayment | Annuity | End |
2 | Interests p.a. | 2% | 1 | 50.000 | -1.250 | -1.750 | -3.000 | 48.250 |
3 | Annuity p.a. | 3.000 | 2 | 48.250 | -1.206 | -1.794 | -3.000 | 46.456 |
4 | Maturity | ?? | 3 | 46.456 | -1.161 | -1.839 | -3.000 | 44.618 |
5 | | | 4 | 44.618 | -1.115 | -1.885 | -3.000 | 42.733 |
| | | | | | | | |
| | | | | | | | |
21 | | | 20 | 8.094 | -202 | -2.798 | -3.000 | 5.297 |
22 | | | 21 | 5.297 | -132 | -2.868 | -3.000 | 2.429 |
23 | | | 22 | 2.429 | -61 | -2.939 | -3.000 | 0 |
The above loan of 50.000 has an interest rate of 2% and an annuity of 3.000.
In the table from C1:H23 the annual development of the remaining loan is displayed.
Based on this helper table I know that the maturity of the loan is 22 years by using the following formula in Cell B4:
B4 = COUNTA(C1:C22)
However, my question is if there is an Excel-Formula that can calculate the maturity in one cell so I do not need the helper table in C1:H23?
I am new to this site and haven't done much in Excel of decades (yes, decades), so I forgotten more than I know now.
Background: I am working on a simple pay sheet checking spreadsheet. One Worksheet is input timesheet for data entry, the complex one does all the calculations (Hourly rate; shift loading; tax formula, etc.) and the final worksheet presents the results in the same format as pay slip. Having finished the complex formulas in the calculation sheet, I am now stuck on condensing the results for the final results on the last sheet. I have try numerous functions including: vlookup, index, match, rank.eq, small and others, as per examples of other question on this site. Sample data is:
+----+-----------------------------------------------------+----------------+------------+--------------+--------+--------+-----+--------+
| | A | B | C | D | E | F | G | H |
+----+-----------------------------------------------------+----------------+------------+--------------+--------+--------+-----+--------+
| 1 | Sample data: | | | | | | | |
| 2 | Monday | Ordinary Hours | 30/04/2018 | Day Shift | 10.85 | 21.85 | 1 | 237.07 |
| 3 | Tuesday | Ordinary Hours | 1/05/2018 | | | 21.85 | 1 | |
| 4 | Wednesday | Ordinary Hours | 2/05/2018 | | | 21.85 | 1 | |
| 5 | Thursday | Ordinary Hours | 3/05/2018 | | | 21.85 | 1 | |
| 6 | Friday | Ordinary Hours | 4/05/2018 | | | 21.85 | 1 | |
| 7 | | | | | | | | |
| 8 | | | | | | | | |
| 9 | Monday | Ordinary Hours | 7/05/2018 | | | 21.85 | 1 | |
| 10 | Tuesday | Ordinary Hours | 8/05/2018 | | | 21.85 | 1 | |
| 11 | Wednesday | Ordinary Hours | 9/05/2018 | Day Shift | 10.85 | 21.85 | 1 | 237.07 |
| 12 | Thursday | Ordinary Hours | 10/05/2018 | Day Shift | 10.85 | 21.85 | 1 | 237.07 |
| 13 | Friday | Ordinary Hours | 11/05/2018 | | | 21.85 | 1 | |
| 14 | | | | | | | | |
| 15 | Monday | Overtime 1.5 | 30/04/2018 | | | 21.85 | 1.5 | |
| 16 | Tuesday | Overtime 1.5 | 1/05/2018 | Overtime 1.5 | 2 | 21.85 | 1.5 | 65.55 |
| 17 | Wednesday | Overtime 1.5 | 2/05/2018 | | | 21.85 | 1.5 | |
| 18 | Thursday | Overtime 1.5 | 3/05/2018 | | | 21.85 | 1.5 | |
| 19 | Friday | Overtime 1.5 | 4/05/2018 | | | 21.85 | 1.5 | |
| 20 | Saturday | Overtime 1.5 | 5/05/2018 | | | 21.85 | 1.5 | |
| 21 | | | | | | | | |
| 22 | Monday | Overtime 1.5 | 7/05/2018 | | | 21.85 | 1.5 | |
| 23 | Tuesday | Overtime 1.5 | 8/05/2018 | | | 21.85 | 1.5 | |
| 24 | Wednesday | Overtime 1.5 | 9/05/2018 | | | 21.85 | 1.5 | |
| 25 | Thursday | Overtime 1.5 | 10/05/2018 | | | 21.85 | 1.5 | |
| 26 | Friday | Overtime 1.5 | 11/05/2018 | | | 21.85 | 1.5 | |
| 27 | Saturday | Overtime 1.5 | 12/05/2018 | | | 21.85 | 1.5 | |
| 28 | | | | | | | | |
| 29 | | | | | | | | |
| 30 | Required result on separate sheet in same workbook: | | | | | | | |
| 31 | Taxable Allowances | Comments | Qty | Rate | Factor | Amount | | |
| 32 | Ordinary Hours | 30/04/2018 | 10.85 | 21.85 | 1 | 237.07 | | |
| 33 | Ordinary Hours | 9/05/2018 | 10.85 | 21.85 | 1 | 237.07 | | |
| 34 | Ordinary Hours | 10/05/2018 | 10.85 | 21.85 | 1 | 237.07 | | |
| 35 | Overtime 1.5 | 1/05/2018 | 2 | 21.85 | 1.5 | 65.55 | | |
| 36 | | | | | | | | |
| 37 | | | | | | | | |
| 38 | | | | | | | | |
| 39 | | | | | | | | |
| 40 | | | | | | | | |
+----+-----------------------------------------------------+----------------+------------+--------------+--------+--------+-----+--------+
I haven't written DAX in a while and I'm having a bit of a hard time putting this together and I am hoping someone could throw in a suggestion.
What I have:
Qty Table (a lot more months than January):
+----------+-----------+----------+
| Location | Date | LaborQty |
+----------+-----------+----------+
| NY | 1/3/2017 | 41.024 |
| NY | 1/4/2017 | 33.836 |
| NY | 1/5/2017 | 20.431 |
| NY | 1/6/2017 | 35.544 |
| NY | 1/7/2017 | 0 |
| NY | 1/9/2017 | 33.337 |
| NY | 1/10/2017 | 41.799 |
| NY | 1/11/2017 | 70.469 |
| NY | 1/12/2017 | 35.514 |
| NY | 1/13/2017 | 31.573 |
| NY | 1/15/2017 | 0 |
| NY | 1/16/2017 | 22.041 |
| NY | 1/17/2017 | 30.518 |
| NY | 1/18/2017 | 47.576 |
| NY | 1/19/2017 | 29.53 |
| NY | 1/20/2017 | 18.155 |
| NY | 1/21/2017 | 0 |
| NY | 1/23/2017 | 31.284 |
| NY | 1/24/2017 | 27.695 |
| NY | 1/25/2017 | 38.907 |
| NY | 1/26/2017 | 16.289 |
| NY | 1/27/2017 | 30.976 |
| NY | 1/28/2017 | 0 |
| NY | 1/30/2017 | 21.434 |
| NY | 1/31/2017 | 16.49 |
+----------+-----------+----------+...etc
Rates Table:
+----------+-----------+------------+-----------+---------+-----------+--------+
| Location | DateFrom | DateTo | MonthFrom | MonthTo | RateType | Amount |
+----------+-----------+------------+-----------+---------+-----------+--------+
| NY | 1/1/2017 | 6/30/2017 | 1 | 6 | LaborRate | 129.7 |
| NY | 7/1/2017 | 9/30/2017 | 7 | 9 | LaborRate | 129.8 |
| NY | 10/1/2017 | 12/31/2017 | 10 | 12 | LaborRate | 129.9 |
| DC | 1/1/2017 | 6/30/2017 | 1 | 6 | LaborRate | 130.1 |
| DC | 7/1/2017 | 9/30/2017 | 7 | 9 | LaborRate | 130.5 |
| DC | 10/1/2017 | 12/31/2017 | 10 | 12 | LaborRate | 130.7 |
+----------+-----------+------------+-----------+---------+-----------+--------+
Desired type of output for the month (e.g. LaborQty x LaborRate):
+-------+----------+-----------+------------+
| Month | LaborQty | LaborRate | Result |
+-------+----------+-----------+------------+
| 1 | 674.22 | 129.74 | 87473.3 |
| 2 | 350 | 129.74 | 45409 |
| 3 | 375 | 129.74 | 48652.5 |
| 4 | 400 | 129.74 | 51896 |
| 5 | 380 | 129.74 | 49301.2 |
| 6 | 500 | 129.74 | 64870 |
| 7 | 550 | 129.76 | 71368 |
| 8 | 600 | 129.76 | 77856 |
| 9 | 675 | 129.76 | 87588 |
| 10 | 700 | 129.98 | 90986 |
| 11 | 780 | 129.98 | 101384.4 |
+-------+----------+-----------+------------+
What I am trying to write:
A DAX measure that will output amount like the one shown in the result column. If I where to write a linq query for picking the correct rate it will look something like this:
LaborRate = db.Rates
.Where(a => a.DateFrom <= SelectedDate & a.DateTo >= SelectedDate & a.RateType == "LaborRate")
.Select(a => a.Amount).Sum();
I have tried a combination of CALCULATE, SUM, SUMX, FILTER, RELATED but I couldn't get it to work. Any advice would be much appreciated. What would be the simplest approach?
I was able to achieve this by doing the following.
Add Month = MONTH(Qty[Date]) as a calculated column to your Qty table.
Create a TotalLaborQty measure in the Qty table as SUM(Qty[LaborQty]).
Define a LaborRate measure in the Rates table as detailed below.
Define a Result measure as [TotalLaborQty] * [LaborRate].
Set them up in a matrix with Qty[Location] and Qty[Month] in the rows and the three measures as the values.
LaborRate =
VAR SelectedMonth = SELECTEDVALUE(Qty[Month])
VAR SelectedLocation = SELECTEDVALUE(Qty[Location])
RETURN CALCULATE(SUM(Rates[Amount]),
FILTER(ALL(Rates),
Rates[MonthFrom] <= SelectedMonth &&
Rates[MonthTo] >= SelectedMonth &&
Rates[Location] = SelectedLocation))
let's say that I have a table like the below:
| | Value 1 | Value 2 | Value 3 | |
|---|---------|---------|---------|---|
| A | 22 | 12 | 3 | |
| A | 5 | 6 | 12 | |
| A | 19 | 9 | 13 | |
| A | 22 | 43 | 31 | |
| B | 7 | 12 | 23 | |
| B | 5 | 5 | 8 | |
| B | 35 | 78 | 9 | |
| B | 45 | 1 | 8 | |
| C | 34 | 56 | 0 | |
| C | 22 | 1 | 14 | |
| C | 13 | 46 | 45 | |
and that I'd need to transform it into the below:
| | Value 1 | Value 2 | Value 3 | |
|---|---------|---------|---------|---|
| A | 22 | 12 | 3 | |
| A | 5 | 6 | 12 | |
| A | 19 | 9 | 13 | |
| A | 22 | 43 | 31 | |
| | 68 | 70 | 59 | |
| | | | | |
| B | 7 | 12 | 23 | |
| B | 5 | 5 | 8 | |
| B | 35 | 78 | 9 | |
| B | 45 | 1 | 8 | |
| | 92 | 96 | 48 | |
| | | | | |
| C | 34 | 56 | 0 | |
| C | 22 | 1 | 14 | |
| C | 13 | 46 | 45 | |
| | 69 | 103 | 59 | |
How could I obtain the desired effect automatically?
There would be n empty rows after each group and the sums of each column within the group.
You can use the Subtotal feature of Excel. Subtotal is in the "Data" tab of the ribbon. To automatically add the totals between groupings. I don't think it adds the blank row. If you absolutely need the blank row, then I can generate some VBA that will work.
I am trying to compare the time value from sheet 1 to sheet 2 and get the close match values in sheet1 -- B, C, D columns. Whenever I refresh the cell A it should automatically update the results in B, C, C, D see expected result
Sheet 1 show current time i.e., cell A1 "=now()"
Sheet1
----------------------------------------------------
| A | B | C | D |
|---------------------------------------------------
| 12:55:00 | | | |
----------------------------------------------------
In sheet 2, data available in 4 columns as below
--------------------------------------------------------
| No | Start | End | Date |
|-------------------------------------------------------
| 1 | 07:36:00 | 08:23:10 | 15/05/2015 |
| 2 | 08:23:10 | 09:10:20 | 15/05/2015 |
| 3 | 09:10:20 | 09:57:30 | 15/05/2015 |
| 4 | 09:57:30 | 10:44:40 | 15/05/2015 |
| 5 | 10:44:40 | 11:31:50 | 15/05/2015 |
| 6 | 11:31:50 | 12:19:00 | 15/05/2015 |
| 7 | 12:19:00 | 13:06:10 | 15/05/2015 |
| 8 | 13:06:10 | 13:53:20 | 15/05/2015 |
| 9 | 13:53:20 | 14:40:30 | 15/05/2015 |
| 10 | 14:40:30 | 15:27:40 | 15/05/2015 |
| 11 | 15:27:40 | 16:14:50 | 15/05/2015 |
| 12 | 16:14:50 | 17:02:00 | 15/05/2015 |
| 13 | 17:02:00 | 18:14:50 | 15/05/2015 |
| 14 | 18:14:50 | 19:27:40 | 15/05/2015 |
| 15 | 19:27:40 | 20:40:30 | 15/05/2015 |
| 16 | 20:40:30 | 21:53:20 | 15/05/2015 |
| 17 | 21:53:20 | 23:06:10 | 15/05/2015 |
| 18 | 23:06:10 | 00:19:00 | 16/05/2015 |
| 19 | 00:19:00 | 01:31:50 | 16/05/2015 |
| 20 | 01:31:50 | 02:44:40 | 16/05/2015 |
| 21 | 02:44:40 | 03:57:30 | 16/05/2015 |
| 22 | 03:57:30 | 05:10:20 | 16/05/2015 |
| 23 | 05:10:20 | 06:23:10 | 16/05/2015 |
| 24 | 06:23:10 | 07:36:00 | 16/05/2015 |
---------------------------------------------------------
Expected
Sheet1 - if the current time is 12:55:00 on 15/05/2015
-----------------------------------------------------------------------------
| A | B | C | D | E |
|-----------------------------------------------------------|---------------|
| 12:55:00 | 7 | 12:19:00 | 13:06:10 | 15/05/2015 |
-----------------------------------------------------------------------------
Sheet1 - if the current time is 03:55:00 on 16/05/2015
-----------------------------------------------------------------------------
| A | B | C | D | E |
|-----------------------------------------------------------|---------------|
| 12:55:00 | 21 | 02:44:40 | 03:57:30 | 16/05/2015 |
-----------------------------------------------------------------------------
for numbers I using the below formula but not sure how to achieve in case of time
=INDEX(A1:A20,MATCH(MIN(ABS(A1:A20-D1)),ABS(A1:A20-D1),0))
Thanks
If we assume that your dates are entered from different days but you want to treat them as though they are all on the same day, you just need to subtract off the days part before doing the comparison.
Since Excel stores dates as days with the decimal representing the hours/seconds, you can simply subtract off the integer part of the value.
Here is that formula. This is an array formula, entered with CTRL+SHIFT+ENTER.
=INDEX(A1:A20,MATCH(MIN(ABS(A1:A20-INT(A1:A20)-D1+INT(D1))),ABS(A1:A20-INT(A1:A20)-D1+INT(D1)),0))
For A1:A20 we subtract off INT(A1:A20). Same thing for D1 except D1 is already being subtracted, so the INT part gets added back in.
Thanks Byron, based on your solution, got an idea and implemented and achieved the desired output see my solution below
Sheet1 convert cell A1 value to number format enter in cell B1
=(A1-INT(A1))*24
In Sheet2 convert cell B to number format -> cell D
----------------------------------------------------------
| A | B | C | D |
|---------------------------------------------------------
| 1 | 07:36:00 | 08:23:10 | 7.6 | forumla "=(B12-INT(B12))*24"
| 2 | 08:23:10 | 09:10:20 | 8.386111111 |
| 3 | 09:10:20 | 09:57:30 | 9.172222222 |
| 4 | 09:57:30 | 10:44:40 | 9.958333333 |
| 5 | 10:44:40 | 11:31:50 | 10.74444444 |
| 6 | 11:31:50 | 12:19:00 | 11.53055556 |
| 7 | 12:19:00 | 13:06:10 | 12.31666667 |
| 8 | 13:06:10 | 13:53:20 | 13.10277778 |
| 9 | 13:53:20 | 14:40:30 | 13.88888889 |
| 10 | 14:40:30 | 15:27:40 | 14.675 |
| 11 | 15:27:40 | 16:14:50 | 15.46111111 |
| 12 | 16:14:50 | 17:02:00 | 16.24722222 |
| 13 | 17:02:00 | 18:14:50 | 17.03333333 |
| 14 | 18:14:50 | 19:27:40 | 18.24722222 |
| 15 | 19:27:40 | 20:40:30 | 19.46111111 |
| 16 | 20:40:30 | 21:53:20 | 20.675 |
| 17 | 21:53:20 | 23:06:10 | 21.88888889 |
| 18 | 23:06:10 | 00:19:00 | 23.10277778 |
| 19 | 00:19:00 | 01:31:50 | 0.316666667 |
| 20 | 01:31:50 | 02:44:40 | 1.530555556 |
| 21 | 02:44:40 | 03:57:30 | 2.744444444 |
| 22 | 03:57:30 | 05:10:20 | 3.958333333 |
| 23 | 05:10:20 | 06:23:10 | 5.172222222 |
| 24 | 06:23:10 | 07:36:00 | 6.386111111 |
---------------------------------------------------------
Now Sheet1 C1 enter the array forumla (shift + Ctrl + Enter)
=INDEX(Sheet2!A12:A35,MATCH(MIN(ABS(Sheet2!D12:D35-Sheet1!B1)),ABS(Sheet2!D12:D35-Sheet1!B1),0))
Sheet1 D1
=VLOOKUP(B3,Sheet2!A12:C35,2,FALSE)
Sheet1 E1
=VLOOKUP(B3,Sheet2!A12:C35,3,FALSE)
Output in Sheet1
------------------------------------------------------------------------------------
| A | B | C | D | E |
|-------------------------------------------------------------------|---------------|
| 07:36:58 | 7.615991667 | 1 | 07:36:00 | 08:23:10 |
-------------------------------------------------------------------------------------
Thanks