Advance your Data & AI career with 50 days of live learning, dataviz contests, hands-on challenges, study groups & certifications and more!
Get registeredGet Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more
I am calculating Number of scan/hour for the warehouse forklift drivers. It shows output for current day, previous day, week to day, MTD and FY YTD.
For calculatin number of Hours, till now I was using 7.5 as shift hours, but, I need to calculate hours based on first scan done by driver and the last scan by driver(timestamp). How can I calculate this hour difference.
The time stamp column looks like this (It doesn't have any start or end, it is just one coloumn)-
For example, for current day I was using:-
// I took 6 as start time of shift-
Solved! Go to Solution.
Well, the solution I provided is not considering employee level granularity since I didn't know much about your model.
Please share the table structrure for the 'ULDs - History' as well and explain the employee identifier (I assume it is the [Packer ID].
A syntax like this should work for you:
YTD Hours =
CALCULATE (
SUM ( CrossJoinedTableName[Difference] ),
ALLEXCEPT ( CrossJoinedTableName, CrossJoinedTableName[Packer ID] ),
DATESYTD ( 'Calendar'[Date] )
)
MTD Hours =
CALCULATE (
SUM ( CrossJoinedTableName[Difference] ),
ALLEXCEPT ( CrossJoinedTableName, CrossJoinedTableName[Packer ID] ),
DATESMTD ( 'Calendar'[Date] )
)You will need to add a column with the weeknumber:
WeekNumber = WEEKNUM(CrossJoinedTableName[Date],2)
WTD Hours =
CALCULATE (
SUM ( CrossJoinedTableName[Difference] ),
ALLEXCEPT (
CrossJoinedTableName,
CrossJoinedTableName[Packer ID],
CrossJoinedTableName[Fin Year],
CrossJoinedTableName[WeekNumber]
)
)
I reckon, it would make things easier if you change the data model by transforming the data in PowerQuery.
Use Group By to summarize the data by Driver and Date
add 2 calculaitons:
FirstScan = Min (timestamp)
LastScan = Max(timestamp)
Then you can add another column to get hours between them.
In the data model, join this table with Date and Driver tables. Done!
You can simply create supoprting columns in your calendar table such as:
FirstStamp = MOD ( MIN ( RELATED ( 'ULDs - History'[Timestamp] ) ), 1 )
LastStamp = MOD ( MAX ( RELATED ( 'ULDs - History'[Timestamp] ) ), 1 )
WorkingHours = LastStamp - FirstStamp
Format them all as time and use them
Thanks for your reponse. But meanwhile no one was answering so till that time I created a cross join table and got this view below-
I created min and max coloumn and difference of max min coloumn to get number of hours.
Now I need to get total number of hours each employee worked week to date, month to date and FY YTD based on above table.
How can I do that?
or is there any easier approach?
Well, the solution I provided is not considering employee level granularity since I didn't know much about your model.
Please share the table structrure for the 'ULDs - History' as well and explain the employee identifier (I assume it is the [Packer ID].
A syntax like this should work for you:
YTD Hours =
CALCULATE (
SUM ( CrossJoinedTableName[Difference] ),
ALLEXCEPT ( CrossJoinedTableName, CrossJoinedTableName[Packer ID] ),
DATESYTD ( 'Calendar'[Date] )
)
MTD Hours =
CALCULATE (
SUM ( CrossJoinedTableName[Difference] ),
ALLEXCEPT ( CrossJoinedTableName, CrossJoinedTableName[Packer ID] ),
DATESMTD ( 'Calendar'[Date] )
)You will need to add a column with the weeknumber:
WeekNumber = WEEKNUM(CrossJoinedTableName[Date],2)
WTD Hours =
CALCULATE (
SUM ( CrossJoinedTableName[Difference] ),
ALLEXCEPT (
CrossJoinedTableName,
CrossJoinedTableName[Packer ID],
CrossJoinedTableName[Fin Year],
CrossJoinedTableName[WeekNumber]
)
)
Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!
Check out the October 2025 Power BI update to learn about new features.
| User | Count |
|---|---|
| 8 | |
| 5 | |
| 4 | |
| 3 | |
| 3 |
| User | Count |
|---|---|
| 24 | |
| 12 | |
| 11 | |
| 9 | |
| 8 |