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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

Row context filter in table having issues

Hi,

Having an issue in solving this simple problem. so I have a table lets say employeehours having following data:

 

talhamm_0-1645289864962.png

 

The requirement is to have hours worked by employees and a calculation which tell whether an employee is in fatigue  or close to or in No fatigue , some thing like this, the below chart sums up by week and week is present in a slicer :

 

talhamm_1-1645290270167.png

 

so if an employee during a week work for less than 50 h, its no fatigue, <=70 close to fatigue and greater than 70 is high fatigue, date column is not present in it , but when I am creating "Is Fatigue" calculation i think it is taking date into consideration , i only need to have that calcultion apply on what the current data is shown in table. Simple switch statement to calculate "is fatigue" column is below:

 

talhamm_3-1645290891625.png

but it is not calculating correctly, the weekly filter is applied here:

 

talhamm_4-1645291019876.png

 

 

1 ACCEPTED SOLUTION

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

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

View solution in original post

4 REPLIES 4
Ashish_Mathur
Super User
Super User

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. 


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
Anonymous
Not applicable

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

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

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:

  1. Format the Date column in the Employee table as a Date data type (not text)
  2. Ensure that the Calendar runs from 2024 to 2030 (the duration as seen in the Employee table)
  3. Create a relationship between 2 tables based on Date (Many to One and Single)

Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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