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

如何创建DAX度量值,按多步骤流转条件统计唯一ID?

正确DAX度量值编写方案

度量1:统计同时存在「Proc1→Verify」和「Verify→Fail」流转的唯一ID

你之前的代码错误在于试图在同一行记录中同时满足两个互斥条件(prevstepid不可能既是Proc1又是Verify)。正确思路是判断每个ID是否同时拥有这两类流转记录:

度量1 = 
CALCULATE (
    DISTINCTCOUNT ( 'table'[id] ),
    FILTER (
        VALUES ( 'table'[id] ),
        CALCULATE ( COUNTROWS ( 'table' ), 'table'[prevstepid] = "Proc1", 'table'[stepid] = "Verify" ) > 0
        && CALCULATE ( COUNTROWS ( 'table' ), 'table'[prevstepid] = "Verify", 'table'[stepid] = "Fail" ) > 0
    )
)

通过VALUES('table'[id])遍历每个唯一ID,分别验证该ID是否存在两类目标记录,同时满足则计入统计。

度量2:统计存在「Proc1→Verify→Reg2→Test2」完整流转路径的唯一ID

需要验证ID同时存在三段连续流转记录:Proc1→Verify、Verify→Reg2、Reg2→Test2:

度量2 = 
CALCULATE (
    DISTINCTCOUNT ( 'table'[id] ),
    FILTER (
        VALUES ( 'table'[id] ),
        CALCULATE ( COUNTROWS ( 'table' ), 'table'[prevstepid] = "Proc1", 'table'[stepid] = "Verify" ) > 0
        && CALCULATE ( COUNTROWS ( 'table' ), 'table'[prevstepid] = "Verify", 'table'[stepid] = "Reg2" ) > 0
        && CALCULATE ( COUNTROWS ( 'table' ), 'table'[prevstepid] = "Reg2", 'table'[stepid] = "Test2" ) > 0
    )
)

度量3:统计存在「Proc1→Verify→Proc3→Pass」完整流转路径的唯一ID

逻辑与度量2一致,验证三段连续流转记录:

度量3 = 
CALCULATE (
    DISTINCTCOUNT ( 'table'[id] ),
    FILTER (
        VALUES ( 'table'[id] ),
        CALCULATE ( COUNTROWS ( 'table' ), 'table'[prevstepid] = "Proc1", 'table'[stepid] = "Verify" ) > 0
        && CALCULATE ( COUNTROWS ( 'table' ), 'table'[prevstepid] = "Verify", 'table'[stepid] = "Proc3" ) > 0
        && CALCULATE ( COUNTROWS ( 'table' ), 'table'[prevstepid] = "Proc3", 'table'[stepid] = "Pass" ) > 0
    )
)

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.21 06:43:17