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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
metcala
Helper III
Helper III

Count active employees with missing timesheets

Hi

 

I have had a look around the forum for help but can't find any solutions that quite match my scenario.

 

I am looking to create a PowerBI matrix as below with 1 to show they were an active employee during that week and do not have an approved timesheet for that week:

 

Employee NameWeek ending - 2 April 2023Week ending - 9 April 2023...
Abc Def01...
Ghi Jkl11...

 

In terms of the data structure I have the following:

 

Employee table

Employee ID

Employee Name

Role ID

Start Date

End Date

 

Timesheet table

Timesheet ID

Employee ID

Period End

Total Hours

Status

 

Date table

Date linked to timesheet table (period end) and employee table (start date and end date)

 

I have tried creating a measure but am struggling to get it working.

 

Here is my current attempt which should just show the total approved hours.

 

 

Total Approved hours =
VAR _date = MAX('Timesheets'[Period End])
RETURN
CALCULATE(
   SUM('Timesheets'[Total Hours],
   FILTER(
      'Employees',
      'Employees'[Start Date] <= _date && 'Employees'[End Date] > _date
   ),
   FILTER(
      'Timesheets',
      'Timesheets'[Status] = "Approved"
   )
)

 

 

 

Any help would be greatly appreciated!

 

Thanks!

1 ACCEPTED SOLUTION

lbendlin_0-1680748862405.png

feel free to modify as needed.  And please don't use "moon dates".  Leave the end date blank if it is not known. Otherwise you create a lot of unnecessary entries in the calendar table.

View solution in original post

4 REPLIES 4
metcala
Helper III
Helper III

Thanks for the response.

 

For simplicity of the example data I will use months rather than weeks

 

Employee table

 

Employee IDEmployee NameRole IDStart DateEnd Date
123John SmithA0011/1/20201/1/2099
124Sally JonesA0021/1/202029/2/2020
124Sally JonesA0031/3/20201/1/2099
125Paul HowardA0041/4/202031/5/20

 

 

Timesheet table

 

Timesheet IDEmployee IDPeriodTotal HoursStatus
100112331/1/20165Approved
100212329/2/20160Approved
100312331/3/20150Approved
100412330/4/20170Approved
100512331/5/20150Approved
100612330/6/20160Pending
100712431/1/20170Approved
100812429/2/20165Approved
100912431/3/20160Pending
101012431/5/20150Approved
101112430/6/20170Approved
101212530/4/20150Approved
101312531/5/20 160Approved

 

Expected outcome

 

To briefly explain the expected outcome:

 

  • If the employee is active and there is not an approved timesheet (i.e. no timesheet or a pending timesheet) there should be a 1
  • If the employee is active and there is an approved timesheet there should be a 0
  • If the employee is not active during that period it should remain blank

 

Employee Name31/1/2029/2/2031/3/2030/4/2031/5/2030/6/20...
John Smith000001 
Sally Jones001100 
Paul Howard   00  

 

Thanks!

 

lbendlin_0-1680748862405.png

feel free to modify as needed.  And please don't use "moon dates".  Leave the end date blank if it is not known. Otherwise you create a lot of unnecessary entries in the calendar table.

Thank you so much! That is exactly what I was after.

 

Really appreciate you taking the time to help me out!

lbendlin
Super User
Super User

Please provide sample data that covers your issue or question completely, in a usable format (not as a screenshot).
https://community.powerbi.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-Forum/ba-...
Please show the expected outcome based on the sample data you provided.

https://community.powerbi.com/t5/Desktop/How-to-Get-Your-Question-Answered-Quickly/m-p/1447523

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.