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

Count Number of Instances of Hours Over 40 Per Week

In the below table example, I'm trying to count the number of instances where more than 40 hours were recorded by end of the week.  The end result would be 2 instances.  Thank you in advance!

 

Employee IDDatePay TypeHoursEnd of WeekWeekly TotalCount over 40Hours Moved to Overtime
16/1/2021Regular86/5/202140  
16/2/2021Regular86/5/202140  
16/3/2021Regular86/5/202140  
16/4/2021Regular86/5/202140  
16/5/2021Regular86/5/202140  
16/6/2021Regular86/12/202148  
16/7/2021Regular86/12/202148  
16/8/2021Regular86/12/202148  
16/9/2021Regular86/12/202148  
16/10/2021Regular86/12/202148  
16/11/2021Regular86/12/20214818
16/12/2021Regular 6/12/202148  
16/13/2021Regular86/19/202140  
16/14/2021Regular86/19/202140  
16/15/2021Regular86/19/202140  
16/16/2021Regular86/19/202140  
16/17/2021Regular86/19/202140  
16/18/2021Regular 6/19/202140  
16/19/2021Regular 6/19/202140  
16/20/2021Regular86/26/202148  
16/21/2021Regular86/26/202148  
16/22/2021Regular86/26/202148  
16/23/2021Regular86/26/202148  
16/24/2021Regular86/26/202148  
16/25/2021Regular86/26/20214818
16/26/2021Regular 6/26/202148  
Total Count     2 

 

 

1 ACCEPTED SOLUTION
v-jingzhang
Community Support
Community Support

Hi @Anonymous 

 

If you already have [End of Week] and [Weekly Total] columns in your table, you can use below measure:

Measure = 
VAR __Table =
    DISTINCT (
        SELECTCOLUMNS (
            'Table',
            "__EmployeeID", [Employee ID],
            "__EndOfWeek", [End of Week],
            "__WeeklyTotal", [Weekly Total]
        )
    )
RETURN
    COUNTROWS ( FILTER ( __Table, [__WeeklyTotal] > 40 ) )

080301.jpg

 

Is this what you want? Let me know if you have any questions.

 

Regards,
Community Support Team _ Jing
If this post helps, please Accept it as the solution to help other members find it.

View solution in original post

4 REPLIES 4
v-jingzhang
Community Support
Community Support

Hi @Anonymous 

 

If you already have [End of Week] and [Weekly Total] columns in your table, you can use below measure:

Measure = 
VAR __Table =
    DISTINCT (
        SELECTCOLUMNS (
            'Table',
            "__EmployeeID", [Employee ID],
            "__EndOfWeek", [End of Week],
            "__WeeklyTotal", [Weekly Total]
        )
    )
RETURN
    COUNTROWS ( FILTER ( __Table, [__WeeklyTotal] > 40 ) )

080301.jpg

 

Is this what you want? Let me know if you have any questions.

 

Regards,
Community Support Team _ Jing
If this post helps, please Accept it as the solution to help other members find it.

Anonymous
Not applicable

Awesome!  You are the man!

Greg_Deckler
Super User
Super User

@Anonymous Seems like:

Measure = 
  VAR __Table = 
    ADDCOLUMNS(
      SELECTCOLUMNS('Table',"__EmployeeID",[Employee ID],"__Date",[Date],"__Hours",[Hours]),
      "__WeekNum",WEEKNUM([__Date])
    )
  VAR __Table2 = SUMMARIZE(__Table,[__EmployeeID],[__WeekNum],"__WeeklyHours",SUM([__Hours))
RETURN
  COUNTROWS(FILTER(__Table2,[__WeeklyHours]>40))

@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...
Anonymous
Not applicable

Thanks for the quick turnaround!  Can you share the pbix file?  I'm missing something. 

 

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.