Forum Discussion
Include Employee start and end date in Utilization %
- Anonymous7 years ago
Utilization = -- Each user must have a unique name. -- If this is not the case, you should -- use a field that uniquely identifies -- a user. Such a field should be marked -- in Power BI as a row identifier. var __visibleUsers = SUMMARIZE( Users, Users[Name], Users[StartDate], Users[TerminationDate] ) var __numberOfWorkingHoursADay = 7.5 var __utilization = AVERAGEX( __visibleUsers, var __userStartDate = Users[StartDate] var __userEndDate = if( Users[TerminationDate] = BLANK(), date(2099, 1, 1), Users[TerminationDate] ) var __totalPossibleWorkingDays = COUNTROWS ( FILTER ( 'Working Dates', 'Working Dates'[IsWorkday] = "Yes", KEEPFILTERS( 'Working Dates'[Date] >= __userStartDate ), KEEPFILTERS( 'Working Dates'[Date] <= __userEndDate ), ) ) var __totalPossibleWorkingHours = __totalPossibleWorkingDays * __numberOfWorkingHoursADay var __totalMandatoryWorkedHours = CALCULATE ( SUM ( 'ActivityUpdates'[Hours] ), 'Working Dates'[IsWorkday] = "Yes" ) var __totalOvertimeWorkedHours = CALCULATE ( SUM ( 'ActivityUpdates'[Hours] ), 'Working Dates'[IsWorkday] = "No" ) var __totalWorkedHours = __totalMandatoryWorkedHour + __totalOvertimeWorkedHours var __totalPossibleWorkingHours = __totalPossibleWorkingHours + __totalOvertimeWorkedHours return divide( __totalWorkedHours, __totalPossibleWorkingHours ) ) RETURN __utilization
Best
Darek
- Anonymous7 years ago
OK, but what do you expect to see in the third column for each row? Would you please put the figures in there? It would be good if you could share a sample file and tell me what the measure should return for the visual(s) you've got in there. It's really hard to see where the formula breaks if there's no expectation set.
I need to see the data model, mate. If you have any cross-filtering, it might screw up the calculations. I just wonder why 'Working Dates' has a column DateAsInteger. You should not compare an int to a date (which __userStartDate and __userEndDate are). This will not return an error because of an automatic conversion since Date is stored as float and an int can be turned into a float as well.
Thanks.
Best
Darek
Well, this is rather not that difficult... Iterate over the visible employees, calculate their utilization for the selected period of time and the aggregate with AVERAGEX. The utilization for the period for one employee can be calculated via this algorithm:
1. Find the total possible hours that could have been worked (T).
2. For any particular employee, find the total official hours worked by the employee (ET).
3. Then find the overtime in the period (EOv) for the employee in question.
4. Then the utilization for her/him would be U = ( ET + EOv ) / (T + EOv).
5. Average U over all visible employees.
You could also do something different:
1. Find the total possible hours that could have been worked (T) plus total possible hours of overtime (Ov).
2. For any particular employee, find the total official hours worked by the employee (ET).
3. Then find the overtime in the period (EOv) for the employee in question.
4. Then the utilization for her/him would be U = ( ET + EOv ) / (T + Ov).
5. Average U over all visible employees.
You have to decide which algorithm expresses better what you want... By the way, there's no need to be concerned about termination dates. The above calculations take them into account automatically through the calculation of working hours of the employees.
Best
Darek
Ok So I'm a bit new at DAX. What would a dax formula look like to:
11. Find the total possible hours that could have been worked (T).
2. For any particular employee, find the total official hours worked by the employee (ET).
3. Then find the overtime in the period (EOv) for the employee in question.
4. Then the utilization for her/him would be U = ( ET + EOv ) / (T + EOv).
5. Average U over all visible employees.
I've included my current DAX Expression - just need to incorprate Hire date and termonation date
- wkeicher7 years ago
Helper III
I think I need to expand on this variable to account for start and end date of an employee...
var workday_available_hours = COUNTROWS(FILTER('Working Dates','Working Dates'[IsWorkday] = "Yes")) * 7.5 * num_selected_employees
- Anonymous7 years agoNot applicable
I don't know the model but if the model is right, you'd do something like this:
Utilization = -- Each user must have a unique name. -- If this is not the case, you should -- use a field that uniquely identifies -- a user. Such a field should be marked -- in Power BI as a row identifier. var __visibleUsers = VALUES( Users[Name] ) var __numberOfWorkingHoursADay = 7.5 var __totalPossibleWorkingDaysForOneUser = COUNTROWS ( FILTER ( 'Working Dates', 'Working Dates'[IsWorkday] = "Yes" ) ) var __totalPossibleWorkingHoursForOneUser = __totalPossibleWorkingDaysForOneUser * __numberOfWorkingHoursADay var __utilization = AVERAGEX( __visibleUsers, var __totalMandatoryWorkedHours = CALCULATE ( SUM ( 'ActivityUpdates'[Hours] ), 'Working Dates'[IsWorkday] = "Yes" ) var __totalOvertimeWorkedHours = CALCULATE ( SUM ( 'ActivityUpdates'[Hours] ), 'Working Dates'[IsWorkday] = "No" ) var __totalWorkedHours = __totalMandatoryWorkedHours + __totalOvertimeWorkedHours var __totalPossibleWorkingHours = __totalPossibleWorkingHoursForOneUser + __totalOvertimeWorkedHours return divide( __totalWorkedHours, __totalPossibleWorkingHours ) ) RETURN __utilization
Best
Darek
- wkeicher7 years ago
Helper III
Hi Derek,
So this works great, however it is not taking into account the users start date and termination date.
Use Case 1:
So if I am Calculating utilization for a user who was terminated within the calendar period, i need to stop adding available work hours as of the termination date.
Use Case 2:
If a user start within the period, I only want to start calculating utilization as of the start date andNOT include available hours prior to the start date.
My Users table has a StartDate and TerminationDate.
Thanks,
Wayne