sum for hours that span more than one day

mbuck84

New Member
Joined
Feb 4, 2020
Messages
1
Office Version
  1. 2016
Platform
  1. Windows
I have a table that calculates values for hour blocks based upon the start/end date and start/end time. The hours are listed in the columns and for each row the user adds the start and end time. No entries are more than 24 hours but very often entries do span two different days, for example 12/31/2019 23:00 to 1/1/2020 6:00.

I want to create a crosstab, hours as the rows and days of the week as columns, that show the sum of scores for each hour block and day. At the moment I have a crosstab using a sumproduct formula: SUMPRODUCT((WEEKDAY(Table2[From Date])=2)*(Table2[0:00])) -example is for midnight Monday hour

The formula uses the from date but does not take into account if the end date is the next day. I want the formula to first determine if the entry spans more than one day by comparing the from date and to date columns, then, if more than one day, sum only those hours that happened for that day. So for the example above, 12/31/2019, which was a Tuesday, would only sum for 23:00 hour block but Wednesday, 1/1/2020 would sum for the 6 hour blocks. I am trying to avoid using VBA. Any help would be greatly appreciated.

Thank you.
 

Excel Facts

Add Bullets to Range
Select range. Press Ctrl+1. On Number tab, choose Custom. Type Alt+7 then space then @ sign (using 7 on numeric keypad)
Show a picture/upload of your table, and also show what your crosstab will look like.
 
Upvote 0

Forum statistics

Threads
1,223,901
Messages
6,175,277
Members
452,629
Latest member
SahilPolekar

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