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
i need to include additional criteria in my Utilization % Calculation that takes into account an employees tenure. In other words if they were active employees or not. A terminated employee should no longer effect utilization as of the termination date. If an employee was hired on 1/1/2019 and was terminated on 6/30/2019, and during that time he worked 8 hours a day, he would be 100% utilized for that period. However, he would only be 50% utilized for all of 2019, because he was terminated on 6/30 (This is incorrect). Neeed assistance in incorprating termination date into the dax calculation for utilization.
Hope you can undestand this.
OK, for one employee the calculation is understandable. But what algorithm would you give for the calculation of utilization of a set of employees? Say you have 2 emps and the period is 1 year. Employee 1 worked fully for the first half of the year only. The other worked full-time for 3/4 of the year. What would be the total utilization for the two workers together?
If I were to define it, it would be something like:
( 1/2 + 3/4 ) / 2 = 5 / 8
Would you agree? If this is so, then the algorithm would be: For each employee calculate the ratio of utilization (it must be between 0 and 1, inclusive) in the selected period and then average over the employees.
Well, what do you say?
Best
Darek
- wkeicher7 years ago
Helper III
Yes that sounds correct.
Bottom line is utilization is calculated at the employee level, and aggregated at the team level. So if employee 1 has 100% utilization for 6 months, and employee 2 has 50% utilization for 1 year, the aggregate utilization for the year would be 75%.
So yes I agree. I just need help including termination date into the utilization calculation.
- Anonymous7 years agoNot applicable
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
- wkeicher7 years ago
Helper III
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
Util =var num_selected_employees = DISTINCTCOUNT('Users'[Name])var workday_available_hours = COUNTROWS(FILTER('Working Dates','Working Dates'[IsWorkday] = "Yes")) * 7.5 * num_selected_employeesvar workday_worked_hours = CALCULATE(SUM('ActivityUpdates'[Hours]), 'Working Dates'[IsWorkday] = "Yes")var non_workday_worked_hours = CALCULATE(SUM('ActivityUpdates'[Hours]), 'Working Dates'[IsWorkday] = "No")return DIVIDE(workday_worked_hours + non_workday_worked_hours,workday_available_hours + non_workday_worked_hours)