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

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.
Show a picture/upload of your table, and also show what your crosstab will look like.
 
Upvote 0

Forum statistics

Threads
1,214,946
Messages
6,122,401
Members
449,081
Latest member
JAMES KECULAH

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