首页 > 解决方案 > 计算除零之外的平均值,忽略功率 bi 度量的切片器

问题描述

我正在创建以下度量来计算所有学生的平均分数,不包括零分数。

measure= calculate(average(table[score]),filter(table, table[score]<>0))

但是,我想将此度量与使用切片器的选定学生分数进行比较。

new measure= calculate(average(table[score]),all(table[student]),filter(table, table[score]<>0))

但是,新度量与学生的分数相同,并且没有忽略切片器。

标签: powerbi

解决方案


您应该使用AVERAGEXandIF来计算基于某些条件排除某些记录的平均值。

Average Excluding Zero =
AVERAGEX (
    Table,
    IF ( Table[Score] <> 0, Table[Score] )
)

然后,

All Students Average Excluding Zero =
CALCULATE (
    [Average Excluding Zero],
    ALL ( Table[Student] )
)

推荐阅读