我有一个 Ratings
表,其中包含一些产品评级:
productKey rating
product-1 4
product-1 5
product-2 3
我想计算每个产品的平均评分:
- 平均值不正确(默认):
(4+5+3)/3 = 12/3 = 4
- 每个产品的平均值:
( (4+5)/2 + 3 )/2 = (4.5 + 3)/2 = 3.75
我设法使用中间表来做到这一点
1)创建每个产品的平均评分表:
RatingsPerProd = SUMMARIZE(Ratings,Ratings[productKey],"averageRating",AVERAGE(Ratings[rating]))
创建下表:
productKey averageRating
product-1 4.5
product-2 3
2) 然后我只需对 averageRating
AVERAGE
但是,我想在原始 Ratings
表上使用 1 个单一度量来执行此操作,但无论我尝试使用 SUMMARIZE
公式做什么,都会收到以下错误:
The expression refers to multiple columns... cannot be converted to a scalar value
如何在原始评分表上的 1 个单项测量中获得每个产品的平均值?
最佳答案
您可以尝试以下公式:
AveragePerProduct =
AVERAGEX (
VALUES ( Ratings[productKey] ),
CALCULATE ( AVERAGE ( Ratings[rating] ) )
)
结果:
关于average - 每个产品的 Power BI 平均评分,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49648602/