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,
You already have a Date column. Ensure that you also have a Calendar Table with a week number column in there. Share the link from where i can download your PBI file.
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
- Anonymous4 years agoNot applicable
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
- Ashish_Mathur4 years agoSuper User
Hi,
All figures in that column are <50, so your formula is correct in returning "No fatigue" in all cells. Where's the problem. Besides, correct for the following:
- Format the Date column in the Employee table as a Date data type (not text)
- Ensure that the Calendar runs from 2024 to 2030 (the duration as seen in the Employee table)
- Create a relationship between 2 tables based on Date (Many to One and Single)