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.
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.