average - 每个产品的 Power BI 平均评分

标签 average powerbi summarization

我有一个 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] ) )
)

结果:

Power BI

关于average - 每个产品的 Power BI 平均评分,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49648602/

相关文章:

mysql - 关于 Powerbi Embedded 报告计划刷新

machine-learning - 通过查找事件来总结文本文档(多文档,即新闻)

sql - 使用 Entity Framework 和MSSQL AVG()函数

split - 比较分割文件的MD5结果与整体的MD5

powerbi - DAX:每天的平均不同值

r - 汇总多组列

crystal-reports - Crystal Report 交叉表计算

MySQL:是否可以计算 MAX( AVG (field) )?

mysql - SQL RIGHT JOIN 不起作用

azure - 尝试获取 Power BI 事件事件(审核日志)时出现 401 错误