March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early bird discount ends December 31.
Register NowBe 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
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 Name | Week ending - 2 April 2023 | Week ending - 9 April 2023 | ... |
Abc Def | 0 | 1 | ... |
Ghi Jkl | 1 | 1 | ... |
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!
Solved! Go to Solution.
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.
Thanks for the response.
For simplicity of the example data I will use months rather than weeks
Employee table
Employee ID | Employee Name | Role ID | Start Date | End Date |
123 | John Smith | A001 | 1/1/2020 | 1/1/2099 |
124 | Sally Jones | A002 | 1/1/2020 | 29/2/2020 |
124 | Sally Jones | A003 | 1/3/2020 | 1/1/2099 |
125 | Paul Howard | A004 | 1/4/2020 | 31/5/20 |
Timesheet table
Timesheet ID | Employee ID | Period | Total Hours | Status |
1001 | 123 | 31/1/20 | 165 | Approved |
1002 | 123 | 29/2/20 | 160 | Approved |
1003 | 123 | 31/3/20 | 150 | Approved |
1004 | 123 | 30/4/20 | 170 | Approved |
1005 | 123 | 31/5/20 | 150 | Approved |
1006 | 123 | 30/6/20 | 160 | Pending |
1007 | 124 | 31/1/20 | 170 | Approved |
1008 | 124 | 29/2/20 | 165 | Approved |
1009 | 124 | 31/3/20 | 160 | Pending |
1010 | 124 | 31/5/20 | 150 | Approved |
1011 | 124 | 30/6/20 | 170 | Approved |
1012 | 125 | 30/4/20 | 150 | Approved |
1013 | 125 | 31/5/20 | 160 | Approved |
Expected outcome
To briefly explain the expected outcome:
Employee Name | 31/1/20 | 29/2/20 | 31/3/20 | 30/4/20 | 31/5/20 | 30/6/20 | ... |
John Smith | 0 | 0 | 0 | 0 | 0 | 1 | |
Sally Jones | 0 | 0 | 1 | 1 | 0 | 0 | |
Paul Howard | 0 | 0 |
Thanks!
Thank you so much! That is exactly what I was after.
Really appreciate you taking the time to help me out!
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
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.
Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.
User | Count |
---|---|
25 | |
16 | |
15 | |
7 | |
7 |
User | Count |
---|---|
37 | |
31 | |
16 | |
16 | |
12 |