如何从矩阵表中提取结果值以创建另一个SUMX量度

时间:2019-09-21 09:14:30

标签: powerbi dax summarize

我想做的是从下表中得出马德里(70.89%)和巴塞罗那(83.92%)的结果,并根据“总生产”量对两个结果进行加权

预期结果如下=(70.89%x 52.550 + 83.92 x 135.100)/(52.550 + 135.100)= 80.27%

这是我为建立矩阵表而创建的度量

Total Production = sum(Database[Production])

Total Working Hours = sum(Database[Working Hours])

TotalExpectedProduction = sum(Database[Expected Production])

Avexpectedprod = divide(sumx(Database;[TotalExpectedProduction]*[Total Working Hours]);sum(Database[Working Hours]))

YTD Productivity =
CALCULATE (
    DIVIDE (
        SUMX (
            SUMMARIZE (
                Database;
                Database[Matchine];
                "AA"; [Total Production] / ( [Total Working Hours] * [Avexpectedprod] )
            );
            [AA] * [Total Working Hours]
        );
        [Total Working Hours];
        0
    );
    DATESYTD ( Calendar[Date]; "30/06" );
    FILTER (
        ALL ( 'Calendar' );
        'Calendar'[Date] <= MAX ( 'Calendar'[Date] )
            && 'Calendar'[Fiscal Year] = MAX ( 'Calendar'[Fiscal Year] )
    )
)

这是我的数据表结构 data table 这是矩阵表和预期结果 Image

非常感谢您的支持 RBN

1 个答案:

答案 0 :(得分:0)

完成!

New2 = 除法(     计算 (         SUMX(VALUES(Database [Location]); [YTD Productivity] * [Total Production]);         Database [Location] =“巴塞罗那”             || Database [Location] =“马德里”     );     计算 (         SUM(Database [Production]);         Database [Location] =“巴塞罗那”             || Database [Location] =“马德里”     ) )