Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!
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.
Solved! Go to Solution.
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)
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.
Can you post the measure that you are currently using to calculate the hours?
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
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")))
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)
Hi,
Thank you so much for your help. It is all working fine now.
You need to close the ALL() statements:
Like this:
ALL(DriverStartStop), DriverStartSt.....
User | Count |
---|---|
140 | |
113 | |
104 | |
77 | |
63 |
User | Count |
---|---|
135 | |
126 | |
110 | |
70 | |
61 |