0

We are trying to perform a Utilization % calculation in DAX and I cannot figure out the forumula. Here's the setup:

Table images are here: http://imgh.us/dax.png

Table 1: There is a [timesheet] Table for our resources (R1, R2, R3, R4). Each timesheet record has a date and number of hours charged.

Table 2: There is a [resource] table with resource [hire date] and [termination date].

Table 3: There is a [calendar] table with available hours for each date. Weekdays have 8 h/day, weekends have 0 h/day

For any given filter context we need to calculate:

Utilization % = (hours charged) / (hours available)

This is not so hard, except for the fact that the (hours available) must only include dates between the [hire date] and [termination date] for each employee. Getting this to work at the aggregate level has been very difficult for us since the calculation must consider each individual employees date range.

The closest we have gotten is:

[hours available] := SUMX(DISTINCT(timesheet[resource_key]), SUM(calendar[utility_hours]))

[hours charged] := SUM(timesheet[bill_hours])

[Utilization %] := [hours charged] / [hours available]

However, this does not perform the resource hire/term date range filtering that is required.

Thanks for any help you can offer!

4

1 回答 1

1

您对 [可用小时数] 的度量值需要修改,以便仅对日历日期介于相应资源的开始日期和终止日期之间的一组过滤行求和,而不是对日历中的所有公用时间进行求和.

[hours available]:=SUMX(DISTINCT(timesheet[resource_key]),CALCULATE(SUM(calendar[utility_hours]),FILTER('calendar',calendar[date_key]>=FIRSTDATE(resources[hire_date_key])),FILTER('calendar',calendar[date_key]<=LASTDATE(resources[termination_date_key]))))

您可能需要修改“>=”和“<=”,具体取决于您是否希望在计算中包括开始日期和结束日期。

编辑:修订版本以获取当月未使用资源但处于“活动状态”的资源

[hours available]:=SUMX(resources,CALCULATE(SUM(calendar[utility_hours]),FILTER('calendar',calendar[date_key]>=FIRSTDATE(resources[hire_date_key])),FILTER('calendar',calendar[date_key]<=LASTDATE(resources[termination_date_key]))))

但是您还需要通过添加零来更改 [收费小时数] 以给出零,而不是空白:

[hours charged]:=SUM(timesheet[bill_hours])+0
于 2015-07-15T09:45:56.377 回答