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
sagarsahoo_123
Helper IV
Helper IV

Request help to write Code for Consecutive months Lower Performer

Hello Team,

I have a requirement in Power BI. I have a table having Employee ID and each Employee having Work Hours information month wise.

I want to display the users who are having less than 6hours average work time for consecutive 3months based on the month selection in the slicer. Need your help to write the DAX formula to acheive this. One sample example is given below.

Emp IDWork TimeMonth
15Jan
28Jan
39Jan
14Feb
27Feb
36Feb
14Mar
24Mar
35Mar

In the above if you look at the work time value for Emploee ID 1 who is less than 6 hours for Jan, Feb and March months.

I need to display those employee ID with Work hours value for last 3 months. Any help would be highly appreciated.

 

Regards,

Sagar

1 ACCEPTED SOLUTION
v-henryk-mstf
Community Support
Community Support

Hi @sagarsahoo_123 ,

 

Try formula like below:

avg_ =
VAR avg_ =
    AVERAGEX (
        FILTER ( ALL ( 'Table' ), 'Table'[Emp ID] = MAX ( 'Table'[Emp ID] ) ),
        CALCULATE ( SUM ( 'Table'[Work Time] ) )
    )
RETURN
    IF ( avg_ < 6, "Yes", "No" )

 

vhenrykmstf_0-1666951943126.png

If the problem is still not resolved, please provide detailed error information and let me know immediately. Looking forward to your reply.


Best Regards,
Henry


If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

2 REPLIES 2
v-henryk-mstf
Community Support
Community Support

Hi @sagarsahoo_123 ,

 

Try formula like below:

avg_ =
VAR avg_ =
    AVERAGEX (
        FILTER ( ALL ( 'Table' ), 'Table'[Emp ID] = MAX ( 'Table'[Emp ID] ) ),
        CALCULATE ( SUM ( 'Table'[Work Time] ) )
    )
RETURN
    IF ( avg_ < 6, "Yes", "No" )

 

vhenrykmstf_0-1666951943126.png

If the problem is still not resolved, please provide detailed error information and let me know immediately. Looking forward to your reply.


Best Regards,
Henry


If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

amitchandak
Super User
Super User

@sagarsahoo_123 , I have this video, in the logic, you add your condition of <6 , which should work

 

Power BI- Customer Purchasing in each of the last 3 months: https://youtu.be/bGtjoccEA38

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.