Supplies are limited. Contact info@espc.tech right away to save your spot before the conference sells out.
Get your discountScore big with last-minute savings on the final tickets to FabCon Vienna. Secure your discount
I would like to calculate the utilization % of the employees and present the data over a matrix table.
I have the following DAX but it doesn’t seem to tally up correctly.
IsWorkHours = IF(DateTable[IsWorkday] = 1, 8, 0)
IsWorkday = SWITCH(WEEKDAY('DateTable'[Date]), 1, 0, 7, 0, 1)
Relationship between databases linked via respective highlighted color.
These are the sample dataset
-EmployeeName | -Country | -CreatedOn | -ModifiedOn | -Status |
Andy Colins | Singapore | 14-Feb-23 | 1-Sep-23 | Inactive |
John Camps | Singapore | 24-Mar-22 | 17-Jan-24 | Active |
Gerald Singh | Singapore | 9-Nov-21 | 17-Jan-24 | Active |
-EmployeeName | -ActivityDate | -DurationInHours | -Status | -ActivityType |
Gerald Singh | 24-Jul-23 | 1 | Approved | Chargeable |
Gerald Singh | 24-Jul-23 | 8 | Approved | Not Available |
Gerald Singh | 25-Jul-23 | 1 | Approved | Chargeable |
Gerald Singh | 25-Jul-23 | 8 | Approved | Not Available |
Gerald Singh | 26-Jul-23 | 1 | Approved | Chargeable |
Gerald Singh | 26-Jul-23 | 8 | Approved | Not Available |
Gerald Singh | 27-Jul-23 | 1 | Approved | Chargeable |
Gerald Singh | 27-Jul-23 | 9 | Approved | Not Available |
Gerald Singh | 28-Jul-23 | 12 | Approved | Not Available |
Gerald Singh | 29-Jul-23 | 8 | Approved | Not Available |
Gerald Singh | 30-Jul-23 | 8 | Approved | Not Available |
Gerald Singh | 31-Jul-23 | 10 | Approved | Not Available |
Gerald Singh | 1-Aug-23 | 10 | Approved | Not Available |
Gerald Singh | 2-Aug-23 | 8 | Approved | Not Available |
Gerald Singh | 3-Aug-23 | 4 | Approved | Not Available |
Gerald Singh | 4-Aug-23 | 8 | Approved | Not Available |
John Camps | 24-Jul-23 | 8 | Approved | Chargeable |
John Camps | 25-Jul-23 | 8 | Approved | Chargeable |
John Camps | 26-Jul-23 | 8 | Approved | Chargeable |
John Camps | 27-Jul-23 | 8 | Approved | Chargeable |
John Camps | 28-Jul-23 | 8 | Approved | Chargeable |
John Camps | 31-Jul-23 | 8 | Approved | Chargeable |
John Camps | 1-Aug-23 | 6 | Approved | Chargeable |
John Camps | 1-Aug-23 | 2 | Approved | Not Available |
John Camps | 2-Aug-23 | 7 | Approved | Chargeable |
John Camps | 2-Aug-23 | 1 | Approved | Not Available |
John Camps | 3-Aug-23 | 6 | Approved | Chargeable |
John Camps | 3-Aug-23 | 2 | Approved | Not Available |
John Camps | 4-Aug-23 | 8 | Approved | Chargeable |
Please note that an employee may not have clocked on a working day. The employee could have clocked multiple times over the same day due to different activity type.
Things that aren’t as I’ve expected. I’ve included the first 2 column data to show calculations
x_Utilization% results
Apologies for the lengthy post. A beginner to pBI. I've been scratching my head hard for the last 1 week over this formula.
Cheers,
Kevin
Solved! Go to Solution.
hi @kevinpbi
I used the sample data which you shared, there are some changes between your and mine data model. Listing everything below.
1. Data model
-There are no limited relationship, like in your datamodel.
-I have used one to many relationship and single direction. Both tables filter Timesheet table.
2. Used Matrix with Year, month, Country, Empoyee Name and Activity type.
Create these measures and put them in Values. I have verified the numbers per logic shared by you. Please test them thoroughly.
Measure1
hi @kevinpbi
I used the sample data which you shared, there are some changes between your and mine data model. Listing everything below.
1. Data model
-There are no limited relationship, like in your datamodel.
-I have used one to many relationship and single direction. Both tables filter Timesheet table.
2. Used Matrix with Year, month, Country, Empoyee Name and Activity type.
Create these measures and put them in Values. I have verified the numbers per logic shared by you. Please test them thoroughly.
Measure1
Thank you very much for the response. It is now reflecting the correct info. Apart from the DAX, the other problem was also on my database relationship which was set incorrectly. It worked when I followed your model.
You're welcome.
Logic I have used for Working Day in Date table
Hi @kevinpbi ,
If I understand correctly, the issue is that you couldn’t calculate the utilization of the employees. Please try the following methods and check if they can solve your problem:
1.Modify the DAX formula for utilization. Enter the following formula.
x_Utilization% =
CALCULATE(
SUMX(
FILTER(
Timesheet,
Timesheet[-Status] = "Approved"
),
Timesheet[-DurationInHours]
),
ALL(DateTable),
'Employee Data'[-CreatedOn] <= MAX(Timesheet[-ActivityDate]) &&
'Employee Data'[-ModifiedOn] >= MIN(Timesheet[-ActivityDate])
) / CALCULATE(
SUMX(
FILTER(
DateTable,
DateTable[IsWorkday] = 1 &&
DateTable[Date] >= MIN('Employee Data'[-CreatedOn]) &&
DateTable[Date] <= MAX('Employee Data'[-ModifiedOn])
),
DateTable[IsWorkHours]
),
ALL(Timesheet)
)
If the above ones can’t help you get it working, could you please provide the DateTable raw data(exclude sensitive data) with Text format? It would be helpful to find out the solution. I am not sure about the data inside the Date Table.
You can refer the following links to share the required info:
How to provide sample data in the Power BI Forum
Best Regards,
Wisdom Wu
Hi Wisdom,
Thank you for the response. However, the output is still incorrect. Please see below screenshot.
Please see below for the Date Table.
generated via
User | Count |
---|---|
12 | |
11 | |
8 | |
6 | |
6 |
User | Count |
---|---|
25 | |
19 | |
14 | |
8 | |
7 |