You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何在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的位置,分别添加了条件判断:

  1. TotalMaintBypass中统计冗余旁路为TRUE的行:通过IF判断是否存在Redundant UPS = "TRUE"的记录,仅当存在时才统计满足Redundant UPS Maintenance Bypass = "TRUE"的行,否则返回0
  2. TotalMaintBypass中统计冗余旁路为FALSE的行:逻辑同上,仅在存在冗余UPS的设备时,统计对应旁路状态为FALSE的行
  3. NoMaintBypass中统计冗余旁路为FALSE的行:同样添加IF判断,仅当设备有冗余UPS时,才将该部分无旁路的记录纳入统计

修改后的逻辑确保:只有当设备配置了冗余UPS(Redundant UPS字段为"TRUE")时,才会把冗余UPS的维护旁路状态计算到总数和无旁路数中,避免无冗余UPS的设备干扰统计结果。

内容的提问来源于stack exchange,提问作者cghanta

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.13 03:22:41