Forum Discussion
Row context filter in table having issues
- Anonymous4 years ago
Hi Anonymous,
Please convert your date fields to the real date value first, then you can try to use the following calculated column formula to get tags based on summary work hour per week for each employee:
Tag = VAR workhour = CALCULATE ( SUM ( Employee[Hours worked] ), FILTER ( Employee, [Employee] = EARLIER ( Employee[Employee] ) ) && YEAR ( [Date] ) = YEAR ( EARLIER ( Employee[Date] ) ) && WEEKNUM ( [Date], 2 ) = WEEKNUM ( EARLIER ( Employee[Date] ), 2 ) ) RETURN IF ( workhour <= 50, "No Fatigue", IF ( workhour > 50 && workhour <= 60, "Close to fatigue", "High fatigue" ) )Regards,
Xiaoxin Sheng
Hi Asish,
Thank you for getting back, PFA, have a look at calculation "IsFatigue" and you can see it is not calculating correctly in table. looks like some row context issues.
I could not attach a file here, so a google drive link for PBIX:
https://drive.google.com/file/d/1xij7GQaFglIN1rMulxERYFYbmFUYXiI4/view?usp=sharing
Hi Anonymous,
Please convert your date fields to the real date value first, then you can try to use the following calculated column formula to get tags based on summary work hour per week for each employee:
Tag =
VAR workhour =
CALCULATE (
SUM ( Employee[Hours worked] ),
FILTER ( Employee, [Employee] = EARLIER ( Employee[Employee] ) )
&& YEAR ( [Date] ) = YEAR ( EARLIER ( Employee[Date] ) )
&& WEEKNUM ( [Date], 2 ) = WEEKNUM ( EARLIER ( Employee[Date] ), 2 )
)
RETURN
IF (
workhour <= 50,
"No Fatigue",
IF ( workhour > 50 && workhour <= 60, "Close to fatigue", "High fatigue" )
)
Regards,
Xiaoxin Sheng