Power BI:列的平均不同计数

时间:2019-02-28 10:57:52

标签: powerbi dax

我有下表:

FactAssign {FactKey,BranchID,ClientID,CustomerName,StartDate,CalendarWeekKey,EmployeeguId}

DimBranch {BranchID,BranchName,Region}

DimClient {clientID,ClientName}

DimCalendar {CalendarWeekKey,WeekEndingDate,CalendarYear,CalendarWeek}

FactAssign表here中的数据

示例行:

| BranchID | ClientID | StartDate | CalendarWeekKey | EmployeeGUID | DayofWeek |
|----------|----------|-----------|-----------------|--------------|-----------|
| 4        | 591      | 3/1/2019  | 20190303        | 783357       | Friday    |
| 4        | 591      | 3/1/2019  | 20190303        | 3744071      | Friday    |
| 4        | 591      | 3/1/2019  | 20190303        | 710020       | Friday    |
| 4        | 591      | 3/1/2019  | 20190303        | 754929       | Friday    |
| 4        | 3032     | 3/1/2019  | 20190303        | 4036981      | Friday    |
| 4        | 5192     | 3/1/2019  | 20190303        | 731638       | Friday    |
| 4        | 5192     | 3/1/2019  | 20190303        | 784118       | Friday    |
| 4        | 5790     | 3/1/2019  | 20190303        | 756802       | Friday    |
| 4        | 5790     | 3/1/2019  | 20190303        | 3748444      | Friday    |
....

我需要的结果 enter image description here

此处CurrentWeek 50是本周BranchID 4的每日不同员工数的平均值。从周一到周五,本周不同的员工数分别为56,53,48,47,46。

如何获得每个分支机构每周 DISTINCTCOUNT 个雇员的 AVERAGE

我使用的达克斯:

Averagex =
CALCULATE (
    AVERAGEX (
        VALUES ( TestingAverageX[CalendarWeekKey] ),
        DISTINCTCOUNT ( TestingAverageX[EmployeeGUID] )
    ),
    FILTER ( TestingAverageX, TestingAverageX[CalendarWeekKey] = 20190303 )
)

关于, 成功

2 个答案:

答案 0 :(得分:0)

我不确定要在哪个过滤器上下文中评估该指标,但可以尝试以下方法:

Rails.application.config.assets.paths << Rails.root.join('app', 'public', 'api', 'assets')

答案 1 :(得分:0)

这里我的问题的解决方案:

AverageX =  CALCULATE (
        AVERAGEX (
            VALUES ( TestingAverageX[StartDate] ),
            CALCULATE ( DISTINCTCOUNT ( TestingAverageX[EmployeeGUID] ) )
        )