Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
gbsand
New Member

Measuring weekly sum of hours worked

Hello,

I currently am using this "Hours" formula which counts the amount of hours an employee has worked in one day. I now need to adjust this formula to create a measure calculating the total amount of hours an employee has worked in one week. How can I adjust this formula? I've tried datesinperiod, dateadd, & weeknum -1 additions to this formula with no luck due to the way this function is built. Thank you!

 

Hours = 
var startpack = MIN('public packs_per_day'[Packed At Time CST])
var startpick = MIN('public picks_per_day'[Picked At Time CST])
var startinventory = MIN('public inventory_change_reasons'[Inventory Changed at Time CST])
var startday = MIN('Clock In/Out'[Clock In Time])
var endpack = MAX('public packs_per_day'[Packed At Time CST])
var endpick = MAX('public picks_per_day'[Picked At Time CST])
var endinventory = MAX('public inventory_change_reasons'[Inventory Changed at Time CST])
var endday = MAX('Clock In/Out'[Actual Clock Out Time])

var starttab = {(startpick),(startpack),(startinventory),(startday)}
var endtab = {(endpick),(endpack),(endinventory),(endday)}

return
IF(
    OR(HOUR(MAXX(endtab,[Value]))=0,HOUR(MINX(starttab,[Value]))=0),
    0,
    IF(
        HOUR(MAXX(endtab,[Value]))=
        HOUR(MINX(starttab,[Value])),
        1,
        HOUR(MAXX(endtab,[Value]))-
        HOUR(MINX(starttab,[Value]))-1.5
    )
)

 

 

3 REPLIES 3
gbsand
New Member

Hi Ryan - Here is some sample data where I have given the hours output of each min/max function:

MIN('public packs_per_day'[Packed At Time CST]) = 6:00am
MIN('public picks_per_day'[Picked At Time CST]) = 6:05am
MIN('public inventory_change_reasons'[Inventory Changed at Time CST]) = 8:00am
MIN('Clock In/Out'[Clock In Time]) = 6:10am
MAX('public packs_per_day'[Packed At Time CST]) = 5:00pm
MAX('public picks_per_day'[Picked At Time CST]) = 4:30pm
MAX('public inventory_change_reasons'[Inventory Changed at Time CST]) = 5:30pm
MAX('Clock In/Out'[Actual Clock Out Time]) = 6:00pm

Then the rest of the function would take the min of all "start" variables and the max of all "end" variables (less 1.5 hours). This is to capture total hours worked in a single day based on these times. The result of the formula from this same data would be 10.5 hours. This is because 6am to 6pm is 12 hours total with 1.5 hours subtracted for expected breaks. Please let me know if you can assist me in creating a function like this, but based on an entire week's worth of hours. Thank you!

 

pls provide some sample data which is your raw data, not the measure you used. That will help to provide the solution for you





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




ryan_mayu
Super User
Super User

could you pls provide the sample data and expected output?





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors