Oct 05 2023 05:56 AM - edited Oct 05 2023 06:01 AM
Hello guys...hoping you can help me here.
I want to create a pivot table where I can see at once the current number of man-days the worker has consumed. The workers are on-call, hence there are so many arrivals and departures.
Example.
NAME ARRIVAL DATE DEPARTURE DATE STATUS MAN-DAYS
Worker 1 Jan. 15, 2023 March 15, 2023 Inactive 40
Worker 1 April 1, 2023 May 31, 2023 Inactive 20
Worker 1 June 15, 2023 Active 70
Worker 2 Jan. 20, 2023 Active 100
Worker 3 Jan. 20, 2023 Jan. 31, 2023 Inactive 5
When I created the Pivot table, it shows like this.
NAME Min. of ARRIVAL DATE Max of DEPARTURE DATE STATUS Sum of MAN-DAYS
Worker 1 Jan. 15, 2023 May 31, 2023 Inactive 60
June 15, 2023 Jan. 0, 1990 Active 70
Worker 2 Jan. 20, 2023 Jan. 0, 1990 Active 100
Worker 3 Jan. 20, 2023 Jan. 31, 2023 Inactive 5
Since Worker 1 has 2 Status on record, his name has 2 lines also. I want to have one line only showing the latest Status.
Worker 1 Jan. 15, 2023 Active 130
Jan. 0, 1990 is a result because the cell is blank as the Worker is still active. No departure date yet. How to make it blank as well.
Thank you all.
Oct 05 2023 06:06 AM
Hi @DeejayJohn,
You can try these steps to make a Pivot table with multiple dates:
Step 1: Create a new pivot table
Step 2: Add the required fields to the pivot table
Step 3: Calculate the total number of man-days consumed to date
To calculate the total number of man-days consumed to date, you can use the following calculated field:
Total Man-Days Consumed to Date =
IF([STATUS] = "Active", [MAX of ARRIVAL DATE] + [MAN-DAYS], [MAN-DAYS])
This calculated field will return the total number of man-days consumed to date, even for workers who are still active.
To add this calculated field to the pivot table, follow these steps:
Step 4: Remove the duplicate rows
To remove the duplicate rows from the pivot table, you can use the following filter:
Please click Mark as Best Response & Like if my post helped you to solve your issue.
This will help others to find the correct solution easily. It also closes the item.
If the post was useful in other ways, please consider giving it Like.
Kindest regards,
Leon Pavesic
(LinkedIn)
Oct 05 2023 10:02 AM
Depends on your Excel platform/version. Creating PivotTable you may add data to data model, add DAX measures like
Arrival:=MIN( daysConsumed[ARRIVAL DATE] )
Departure:=IF( "Active" IN VALUES(daysConsumed[STATUS]), BLANK(), MAX(daysConsumed[DEPARTURE DATE]) )
ManDays:=SUM( daysConsumed[MAN-DAYS] )
Current Status:=IF( "Active" IN VALUES(daysConsumed[STATUS]), "Active", "Inactive" )
and use them creating PivotTable
Oct 07 2023 03:25 AM
Thanks. I got an idea on what steps to follow.
I'm just having problem on the formula in calculated field.
Oct 07 2023 03:31 AM - edited Oct 07 2023 03:33 AM
Thanks Sergei.
This is the output I want to have.
But I don't know how to use your formula.
I am using Excel 365.
Oct 07 2023 09:29 AM
SolutionCreating PivotTable add data to data model
Add Name to Rows.
In PivotTable pane right click on table name and Add measure
add measures one by one
Finalize PivotTable with them
Oct 07 2023 11:54 PM
latest status 2023/6/15?
Worker 1 | 2023/6/15 | Active | 130 | |
Worker 2 | 2023/1/20 | Active | 100 | |
Worker 3 | 2023/1/20 | 2023/1/31 | Inactive | 5 |
create temp table aa as
select f01,f02,f03,f04,sum(f05) total,max(f02) m from showing_the_latest_Status group by f01;
cli_no_header;
select colExclude[m] from aa;
Oct 08 2023 04:58 AM
Oct 08 2023 07:21 AM
Arrival shows MIN ARRIVAl date
Didn't catch how ON LEAVE shall work, it's just possible latest status together with Active or not. Perhaps
Current Status:=VAR statuses=VALUES(daysConsumed[STATUS])
RETURN IF("On leave" IN statuses,
"On leave",
IF( "Active" IN statuses, "Active", "Inactive" ) )
If you generate small sample file with possible cases is source and desired answer it'll be easier to check the logic.