如何在DAX度量值中为冗余UPS维护旁路添加IF条件
修改后的DAX度量值代码及说明
以下是添加了Redundant UPS条件判断后的DAX代码:
UPS %No Maint Bypass = VAR TotalMaintBypass = COUNTROWS ( FILTER ( ALL ( 'UPS (2)' ), 'UPS (2)'[UPS Maintenance Bypass] = "TRUE" ) ) + COUNTROWS ( FILTER ( ALL ( 'UPS (2)' ), 'UPS (2)'[UPS Maintenance Bypass] = "FALSE" ) ) + IF( COUNTROWS(FILTER(ALL('UPS (2)'), 'UPS (2)'[Redundant UPS] = "TRUE")) > 0, COUNTROWS ( FILTER ( ALL ( 'UPS (2)' ), 'UPS (2)'[Redundant UPS] = "TRUE" && 'UPS (2)'[Redundant UPS Maintenance Bypass] = "TRUE" ) ), 0 ) + IF( COUNTROWS(FILTER(ALL('UPS (2)'), 'UPS (2)'[Redundant UPS] = "TRUE")) > 0, COUNTROWS ( FILTER ( ALL ( 'UPS (2)' ), 'UPS (2)'[Redundant UPS] = "TRUE" && 'UPS (2)'[Redundant UPS Maintenance Bypass] = "FALSE" ) ), 0 ) VAR NoMaintBypass = COUNTROWS ( FILTER ( ALL ( 'UPS (2)' ), 'UPS (2)'[UPS Maintenance Bypass] = "FALSE" ) ) + IF( COUNTROWS(FILTER(ALL('UPS (2)'), 'UPS (2)'[Redundant UPS] = "TRUE")) > 0, COUNTROWS ( FILTER ( ALL ( 'UPS (2)' ), 'UPS (2)'[Redundant UPS] = "TRUE" && 'UPS (2)'[Redundant UPS Maintenance Bypass] = "FALSE" ) ), 0 ) RETURN DIVIDE ( NoMaintBypass, TotalMaintBypass, 0 ) * 100 + 0
关键修改说明
针对你提到的三个使用Redundant UPS Maintenance Bypass的位置,分别添加了条件判断:
- TotalMaintBypass中统计冗余旁路为TRUE的行:通过IF判断是否存在
Redundant UPS = "TRUE"的记录,仅当存在时才统计满足Redundant UPS Maintenance Bypass = "TRUE"的行,否则返回0 - TotalMaintBypass中统计冗余旁路为FALSE的行:逻辑同上,仅在存在冗余UPS的设备时,统计对应旁路状态为FALSE的行
- NoMaintBypass中统计冗余旁路为FALSE的行:同样添加IF判断,仅当设备有冗余UPS时,才将该部分无旁路的记录纳入统计
修改后的逻辑确保:只有当设备配置了冗余UPS(Redundant UPS字段为"TRUE")时,才会把冗余UPS的维护旁路状态计算到总数和无旁路数中,避免无冗余UPS的设备干扰统计结果。
内容的提问来源于stack exchange,提问作者cghanta
相关产品推荐
相关产品推荐

