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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
corange
Post Patron
Post Patron

Total working hours / week

Hi everyone,

 

I am new to POWER BI and I am struggling to get to where I need. I have a set of data with daily start and finish time / employee. I have calculated the duration in minutes and then converted it in decimal hours.

 

I need to show the weekly average hours and then group them into categories (less than 20 hours / week , between 20hrs and 35 hours / week, and more than 35hrs / week). I have looked in the forum to obtain the total hours / week, creating a week number column but I am lost and can't achieve what I am after.

 

Would you be able to help me.

 

Thanks in advance.

1 ACCEPTED SOLUTION
tex628
Community Champion
Community Champion

 

HOURLY BRACKETS = VAR DRIVER = DriverStartStop[Driver]
VAR WEEK = DriverStartStop[OUR NEW CREATED SUB-PERIOD]
RETURN
IF(CALCULATE(SUM(DriverStartStop[Decimal Hours Driver]), ALL(DriverStartStop), DriverStartStop[Driver]=DRIVER, DriverStartStop[weeknum]=WEEK)<20,"Less than 20hrs",
IF(CALCULATE(SUM(DriverStartStop[Decimal Hours Driver]), ALL(DriverStartStop), DriverStartStop[Driver]=DRIVER, DriverStartStop[weeknum]=WEEK)<=35,"Btw 20hrs & 35 hrs",
IF(CALCULATE(SUM(DriverStartStop[Decimal Hours Driver]), ALL(DriverStartStop), DriverStartStop[Driver]=DRIVER, DriverStartStop[weeknum]=WEEK)>35,"More than 35hrs")))

Instead of referencing the week we now want to reference the new sub period that we are using instead (P1_S1 ... P1_S2 ... and so on)

 


Connect on LinkedIn

View solution in original post

29 REPLIES 29

Hi tex628,

 

Just forgot about what I just said. It must be the return from holiday that is playing a trick on me.

 

It is fine. I have got the right results in both instance.

 

The only thing I can't figure out is that 5+hours being classified as 35hours +. It is one of those week that was falling into two periods. Capture.PNG

tex628
Community Champion
Community Champion

Can you post the measure that you are currently using to calculate the hours? 


Connect on LinkedIn

Hi,

 

It is really weird what is happening. When I click on the count of ID for more than 35hours, ID 7173 shows up under this bracket but only display 5:40 hours. However, from another table, if I click on the same driver, the table updates and shows the correct amount.

 

My formula is

DifferenceDur = SUM(StartStop[LastActionDec]) - SUM(StartStop[FirstActionDec])

Decimal Hours (Hrs) = ([DifferenceDur])/60

tex628
Community Champion
Community Champion

And for the grouping? 🙂


Connect on LinkedIn

Hi,

 

HOURLY BRACKETS = VAR DRIVER = DriverStartStop[Driver]
VAR WEEK = DriverStartStop[weeknum]
RETURN
IF(CALCULATE(SUM(DriverStartStop[Decimal Hours Driver]), ALL(DriverStartStop), DriverStartStop[Driver]=DRIVER, DriverStartStop[weeknum]=WEEK)<20,"Less than 20hrs",IF(CALCULATE(SUM(DriverStartStop[Decimal Hours Driver]), ALL(DriverStartStop), DriverStartStop[Driver]=DRIVER, DriverStartStop[weeknum]=WEEK)<=35,"Btw 20hrs & 35 hrs",IF(CALCULATE(SUM(DriverStartStop[Decimal Hours Driver]), ALL(DriverStartStop), DriverStartStop[Driver]=DRIVER, DriverStartStop[weeknum]=WEEK)>35,"More than 35hrs")))

tex628
Community Champion
Community Champion

 

HOURLY BRACKETS = VAR DRIVER = DriverStartStop[Driver]
VAR WEEK = DriverStartStop[OUR NEW CREATED SUB-PERIOD]
RETURN
IF(CALCULATE(SUM(DriverStartStop[Decimal Hours Driver]), ALL(DriverStartStop), DriverStartStop[Driver]=DRIVER, DriverStartStop[weeknum]=WEEK)<20,"Less than 20hrs",
IF(CALCULATE(SUM(DriverStartStop[Decimal Hours Driver]), ALL(DriverStartStop), DriverStartStop[Driver]=DRIVER, DriverStartStop[weeknum]=WEEK)<=35,"Btw 20hrs & 35 hrs",
IF(CALCULATE(SUM(DriverStartStop[Decimal Hours Driver]), ALL(DriverStartStop), DriverStartStop[Driver]=DRIVER, DriverStartStop[weeknum]=WEEK)>35,"More than 35hrs")))

Instead of referencing the week we now want to reference the new sub period that we are using instead (P1_S1 ... P1_S2 ... and so on)

 


Connect on LinkedIn

Hi,

 

Thank you so much for your help. It is all working fine now.

 

 

tex628
Community Champion
Community Champion

No worries! 🙂


Connect on LinkedIn
tex628
Community Champion
Community Champion

You need to close the ALL() statements:
image.png
Like this:
ALL(DriverStartStop), DriverStartSt.....



Connect on LinkedIn

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

Find out what's new and trending in the Fabric Community.