Forum Discussion
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.
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)
29 Replies
- tex628
Community Champion
Hello,
I would make a calculated column to classify each row.Column = VAR person = 'Table'[Person] VAR week = 'Table'[Week] return IF( Calculate( Sum( 'Table'[Hours] ); All( 'Table' ); 'Table'[Person] = person; 'Table'[Week] = week) < 20 ; "Less than 20 Hours" ; IF( Calculate( Sum( 'Table'[Hours] ); All( 'Table' ); 'Table'[Person] = person; 'Table'[Week] = week) <= 35 ; "Between 20 and 35 Hours" ; "More than 35 Hours" )
You might need to change your week column to a year/week column if you have dates that pass through more than one year.
- corange
Post Patron
Hi tex628,
This didnt work for me. I will try to be more specific in my explanation.
I have got a list of employee ID with their daily starting and finish time. For each daily log, I did finish - start time using DATEDIFF to calculate duration in minutes. I have then use DATEDIFF / 60 to obtain Decimal Hour.
I now need to calculate the weekly ave working hours and group employees into categories <20hrs, 20hrs to 35hrs, More than 35 hrs. The graphs need to display weekly decimal hours with the legend 20hours etc... but we work by period. In a month, we have 2 periods (1st period runs from 1st to the 15, Period 2 runs from 16 to end of the month).
What other information would you require to be able to guide me here?
- tex628
Community Champion
Your intensions are quite clear! :-) What was the result of the column i provided, did it not work at all? If possible, post a picture.
/ J