Calculate difference between two times using Pivot Table Calculated Field

mouzzampk2014

New Member
Joined
Sep 6, 2016
Messages
24
Hi, I tried different steps two subtract two times (cell b-cell a) using calucated fieldd and output the total in cell c but my output is totally wrong. Could someone look into this for me. Much appreciated. Shall I upload sample file? Thank you
 
exactly the same:
screenshot-71.png

Could you please click on request access and then I will get notification and I will allow. If that's okay?
 
Upvote 0

Excel Facts

Create a Pivot Table on a Map
If your data has zip codes, postal codes, or city names, select the data and use Insert, 3D Map. (Found to right of chart icons).
try to find option: anyone with this link can edit this item or something similar

and don't quote whole post, please!
 
Last edited:
Upvote 0
I found it on OneDrive please try now [FONT=Verdana,Arial,Tahoma,Calibri,Geneva,sans-serif]https://1drv.ms/x/s!Ah6KmIniO5ZMgY93boeZu5reJP81DQ I am going to read all the forum conditions tonight. You guys are so helpful. And i am sorry for been noob[/FONT]
 
Upvote 0
first try with PowerQuery

Code:
[SIZE=1]// Table1
let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"DATE", type date}, {"SERNO", type text}, {"INITS", type text}, {"STATE", Int64.Type}, {"MAX_CPHIST_TIME", type time}, {"MIN_CPHIST_TIME", type time}}),
    #"Grouped Rows" = Table.Group(#"Changed Type", {"DATE", "INITS"}, {{"Max", each List.Max([MAX_CPHIST_TIME]), type time}, {"Min", each List.Min([MIN_CPHIST_TIME]), type time}}),
    #"Inserted Time Subtraction" = Table.AddColumn(#"Grouped Rows", "Subtraction", each [Max] - [Min], type duration)
in
    #"Inserted Time Subtraction"[/SIZE]

then create PivotTable from QueryTable

[Table="width:, class:head"]
[tr=bgcolor:#FFFFFF][td=bgcolor:#DDEBF7]DATE[/td][td=bgcolor:#DDEBF7](All)[/td][td][/td][td][/td][/tr]

[tr=bgcolor:#FFFFFF][td][/td][td][/td][td][/td][td][/td][/tr]

[tr=bgcolor:#FFFFFF][td=bgcolor:#DDEBF7]INITS[/td][td=bgcolor:#DDEBF7]Sum of Max[/td][td=bgcolor:#DDEBF7]Sum of Min[/td][td=bgcolor:#DDEBF7]Sum of Subtraction[/td][/tr]

[tr=bgcolor:#FFFFFF][td]ABH[/td][td]
20:49:00​
[/td][td]
22:06:00​
[/td][td]
0.22:43:00​
[/td][/tr]

[tr=bgcolor:#FFFFFF][td]BR[/td][td]
07:25:00​
[/td][td]
20:32:00​
[/td][td]
0.10:53:00​
[/td][/tr]

[tr=bgcolor:#FFFFFF][td]STF[/td][td]
16:10:00​
[/td][td]
04:25:00​
[/td][td]
0.11:45:00​
[/td][/tr]

[tr=bgcolor:#FFFFFF][td=bgcolor:#DDEBF7]Grand Total[/td][td=bgcolor:#DDEBF7]
20:24:00
[/td][td=bgcolor:#DDEBF7]
23:03:00
[/td][td=bgcolor:#DDEBF7]
1.21:21:00
[/td][/tr]
[/table]
 
Last edited:
Upvote 0
When I copy and past the above I get `[FONT=Verdana,Arial,Tahoma,Calibri,Geneva,sans-serif]Expression.Error: We couldn't find an Excel table named 'Table1'.`[/FONT]
 
Upvote 0
check Workbook Queries
in your example file the name of the table is: Table1

screenshot-72.png


screenshot-73.png


if your table has different name simply change name in code
 
Last edited:
Upvote 0
I changed the Table 1 to Raw_Data_Pivot but now I am getting Expression.Error: The column 'SERNO' of the table wasn't found.
2E5Ezqq.jpg
[/URL][/IMG]<strike></strike>
 
Last edited:
Upvote 0

Forum statistics

Threads
1,223,247
Messages
6,171,007
Members
452,374
Latest member
keccles

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top