Calculating hours between columns

exceluser9

Active Member
Joined
Jun 27, 2015
Messages
388
Hi Team,

I have below data and I would require a formula to see how many activity each person has processed in an hour, for every hour I would like to show the progress in different table. I want to see the progress for 12 hours. I input the processor name in column A in sheet 1 and 2 to get the results

Sheet 3
Column ACoulmn BColumn CColumn D
ProcessorActivityProcessed onMinutes
PeterCall12/03/2019 04:105
PeterChat12/03/2019 04:156
PeterChat12/03/2019 04:186
JamesIT issue12/03/2019 04:085
PaulChat12/03/2019 04:166
PeterCall12/03/2019 05:015
HelenChat12/03/2019 05:106
HarryIT issue12/03/2019 06:166
HarryTicket12/03/2019 07:164
HarryChat12/03/2019 08:166
HarryChat12/03/2019 08:166
HarryChat12/03/2019 09:166

<tbody>
</tbody>


Expected result sheet 1 only to count activity vs time
Column AColumn BColumn CColumn DColumn EColumn F
Processor4 PM to 5 PM5 PM to 6 PM7 PM to 8 PM8 PM to 9 PM9 PM to 10 PM
Peter31
James1
Paul1
Helen1
Harry1121

<tbody>
</tbody>


Also I would require one more formula to see how many minutes each person spent on the activity in each hour based on the minutes provided in minutes coulmn D

Expected result sheet 2, total time spent by processor on each activity for every hour
Column AColumn BColumn CColumn DColumn EColumn FColumn G
ProcessorActivity4 PM to 5 PM5 PM to 6 PM7 PM to 8 PM8 PM to 9 PM9 PM to 10 PM
PeterCall5
PeterChat12
JamesIT issue5
PaulChat6
PeterCall5
HelenChat6
HarryIT issue6
HarryChat12
HarryChat6

<tbody>
</tbody>


Thanks
 
Last edited:
sure but this is PowerQuery (Get&Transform) not a formula ;)

if you are interested here is:

Code:
[SIZE=1]// First
let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    Type = Table.TransformColumnTypes(Source,{{"Processor", type text}, {"Activity", type text}, {"Processed on", type time}, {"Minutes", Int64.Type}}),
    Start = Table.AddColumn(Type, "Start of Hour", each Time.StartOfHour([Processed on]), type time),
    End = Table.AddColumn(Start, "End of Hour", each Time.EndOfHour([Processed on]), type time),
    Group = Table.Group(End, {"Processor", "Start of Hour", "End of Hour"}, {{"Count", each Table.RowCount(_), type number}})
in
    Group[/SIZE]

Code:
[SIZE=1]// Second
let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    Type = Table.TransformColumnTypes(Source,{{"Processor", type text}, {"Activity", type text}, {"Processed on", type time}, {"Minutes", Int64.Type}}),
    Start = Table.AddColumn(Type, "Start of Hour", each Time.StartOfHour([Processed on]), type time),
    End = Table.AddColumn(Start, "End of Hour", each Time.EndOfHour([Processed on]), type time),
    Group = Table.Group(End, {"Processor", "Activity", "Start of Hour", "End of Hour"}, {{"Count", each Table.RowCount(_), type number}, {"Minutes", each List.Sum([Minutes]), type number}})
in
    Group[/SIZE]

example file
 
Last edited:
Upvote 0

Excel Facts

Test for Multiple Conditions in IF?
Use AND(test, test, test, test) or OR(test, test, test, ...) as the logical_test argument of IF.
PowerQuery is pretty nice!

Using my formula version and some formatting (blank 0), you can get this:

Clip0024.jpg
 
Upvote 0
Hi Kweaver.

Can we amend 18 - 19 to 6 - 7? i will be showing the data only from 12 PM to 10 PM.

And would require a formula formula to should hourly data and for two hours.

The table which sandy666 gave is my requirement
 
Upvote 0
So,
Data - Show Queries - on the right side you'll see Workbook Queries tables: choose the one you want to have and dbl click - in new window (PowerrQuery Editor) find Advanced Editor and open it then you'll see the same code as in the post.

How to use? Simply add more data to your source table then right click on green table and select refresh

edit:
or just use Ctrl+Alt+F5
 
Last edited:
Upvote 0
Hi Sandy,

Im not finding below details could you give screenshot? Im not finding an option to copy paste this code

choose the one you want to have and dbl click - in new window (PowerrQuery Editor) find Advanced Editor and open it then you'll see the same code as in the post.
 
Last edited:
Upvote 0

Forum statistics

Threads
1,215,206
Messages
6,123,636
Members
449,109
Latest member
Sebas8956

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