Power BI DAX平均AVG

时间:2019-06-28 20:00:58

标签: powerbi dax

我希望显示结果,例如: AVG GROUP 1采取品牌平均水平,然后平均该组。因此,

avg BRAND J = 8.4
avg BRAND K = 4.8
avg BRAND L = 4.9 

然后,AVG GROUP 1 = 6.03 NOT 6.6

然后将对所有组继续进行。

谢谢

数据表

GROUP      BRAND       PERCENT CHANGE
GROUP 1    BRAND J     4.8%
GROUP 1    BRAND J     12.0%
GROUP 1    BRAND K     4.8%
GROUP 1    BRAND L     4.9%
GROUP 2    BRAND M     8.0%
GROUP 3    BRAND A     4.0%
GROUP 4    BRAND B     8.0%
GROUP 4    BRAND B     15.0%
GROUP 4    BRAND C     8.0%
GROUP 4    BRAND N     7.0%
GROUP 5    BRAND D     5.0%
GROUP 5    BRAND E     4.0%
GROUP 5    BRAND E     6.0%
GROUP 5    BRAND E     6.0%

1 个答案:

答案 0 :(得分:2)

创建度量:

Group Average =
AVERAGEX (
    SUMMARIZE (
        Data,
        Data[Group],
        Data[Brand],
        "Brand Average", AVERAGE ( Data[Percent Change] )
    ),
    [Brand Average]
)

其中“数据”是表名。

结果:

enter image description here

更详细的结果:

enter image description here

工作原理: 首先,我们按组和品牌汇总您的数据,然后分别计算平均值。然后,我们使用AVERAGEX迭代汇总表,并计算平均值的平均值。

编辑:

要过滤出具有1个品牌的组,请修改度量:

Group Average =
AVERAGEX(
        SUMMARIZE (
            Data,
            Data[Group],
            Data[Brand],
            "Brand Average", AVERAGE ( Data[Percent Change] ),
            "Brand Count", CALCULATE(COUNT(Data[BRAND]), ALLEXCEPT(Data, Data[GROUP])),
IF([Brand Count] > 1, [Brand Average])
)

您将获得:

enter image description here