首页 > 解决方案 > 如何使用 DAX 在 Power BI 中计算加权平均值?

问题描述

我的数据表如下所示:

Country | Total | Days 
A | 56 | 3
B | 23  | 5
C | 22 | 2
D | 90 | BLANK

我想找到由 4 个步骤组成的加权平均值

Step 1 : Multiply Total into Days where Days is not blank (i.e to consider only non blank values). lets name the new column formed "Product:
Step 2 : Take the Subtotal sum of the PRODUCT
Step 3 : Take the Subtotal sum of TOTAL
Step 4 : Step 2 / Step 3

即使在 EXCEL 上完成,我也无法在 Power BI 中执行此操作。有人可以帮我吗?

标签: powerbidax

解决方案


您可以创建以下度量 -

Measure 2 = DIVIDE(sumx('Table','Table'[Days]*'Table'[Total]), SUM('Table'[Total]))

推荐阅读