The goal: In excel, determine hour by hour how much I am paying in labor versus how much we make in sales during that hour.
Tables:
Timesheets: Simple employee name, start time, stop time, date
Timesheets EDIT (separate table): unpivoted start and stop time. Now I have a column called shift, which indicates if it is shift start or end, the associated time, and an index so I know which start and end belong together.
Calendar: Excel date table
TimeTable: has every minute of a whole day and the hour that I want it to correspond to. e.g. 1:13 PM has a 13 in the Hour column.
This is the DAX that I am using right now:
This is what it yields:
[TABLE="class: grid, width: 500"]
<tbody>[TR]
[TD][/TD]
[TD]5[/TD]
[TD]6[/TD]
[TD]7[/TD]
[TD]8[/TD]
[TD]9[/TD]
[TD]10[/TD]
[TD]11[/TD]
[TD]12[/TD]
[TD]Grand Total[/TD]
[/TR]
[TR]
[TD]2019[/TD]
[TD]10.33[/TD]
[TD]35.54[/TD]
[TD]15.24[/TD]
[TD]89.13[/TD]
[TD]50.50[/TD]
[TD]99.81[/TD]
[TD]108.73[/TD]
[TD]9.78[/TD]
[TD]11,441[/TD]
[/TR]
</tbody>[/TABLE]
I am basically trying to count the rows in the timetable that fall between start and end. The two tables are related by the time column, but the calculated fields are only showing the values summed for the hour in which the shift started. If somebody started a shift at 3:15AM, the value under the column '3' would read 45. If another person started at 3:45 am, that sum still works, and will show 60 minutes total. What it WON'T catch, is the full 60 minutes if somebody starts at 2:45 am and ends at 4:15 am. The grand total is correct, but I really need to be able to slice and dice this result.
Any suggestions?
Tables:
Timesheets: Simple employee name, start time, stop time, date
Timesheets EDIT (separate table): unpivoted start and stop time. Now I have a column called shift, which indicates if it is shift start or end, the associated time, and an index so I know which start and end belong together.
Calendar: Excel date table
TimeTable: has every minute of a whole day and the hour that I want it to correspond to. e.g. 1:13 PM has a 13 in the Hour column.
This is the DAX that I am using right now:
Code:
SumHours:=sumx('Timesheets Edit',round(RELATED('Pay Rates'[Rate])*countrows(filter(TimeTable,if('Timesheets Edit'[Shift]="Start",TimeTable[Time]>'Timesheets Edit'[Time] && TimeTable[Time]<=LOOKUPVALUE('Timesheets Edit'[Time],'Timesheets Edit'[Shift],"End",'Timesheets Edit'[Index],'Timesheets Edit'[Index]),0)))/60,2))
This is what it yields:
[TABLE="class: grid, width: 500"]
<tbody>[TR]
[TD][/TD]
[TD]5[/TD]
[TD]6[/TD]
[TD]7[/TD]
[TD]8[/TD]
[TD]9[/TD]
[TD]10[/TD]
[TD]11[/TD]
[TD]12[/TD]
[TD]Grand Total[/TD]
[/TR]
[TR]
[TD]2019[/TD]
[TD]10.33[/TD]
[TD]35.54[/TD]
[TD]15.24[/TD]
[TD]89.13[/TD]
[TD]50.50[/TD]
[TD]99.81[/TD]
[TD]108.73[/TD]
[TD]9.78[/TD]
[TD]11,441[/TD]
[/TR]
</tbody>[/TABLE]
I am basically trying to count the rows in the timetable that fall between start and end. The two tables are related by the time column, but the calculated fields are only showing the values summed for the hour in which the shift started. If somebody started a shift at 3:15AM, the value under the column '3' would read 45. If another person started at 3:45 am, that sum still works, and will show 60 minutes total. What it WON'T catch, is the full 60 minutes if somebody starts at 2:45 am and ends at 4:15 am. The grand total is correct, but I really need to be able to slice and dice this result.
Any suggestions?