countifs 的 Power BI 多个条件

Power BI multiple conditions for countifs

我正在尝试在此处为以下组合项目和代码实现计数。

A 和 B 列有项目和代码,C 列是我的状态。

1.if 同一个项目代码后有“YP”,代码后没有“YP”,那么我的状态是“NotOKay”。

示例;

2.There 相同项目的代码后没有“YP”,那么我的状态是“好的”。

enter image description here

您可以尝试以下适用于 measurecolumn-

的代码
ok_not_ok = 

VAR item_count = 
CALCULATE(
    COUNT(your_table_2[item]),
    ALLEXCEPT(your_table_2,your_table_2[item])
)

VAR item_count_with_yp =
CALCULATE(
    COUNT(your_table_2[item]),
    FILTER(
        ALLEXCEPT(your_table_2,your_table_2[item]),
        RIGHT(your_table_2[code],3) = "-YP"            
    )
) + 0

RETURN IF(
    item_count_with_yp = 0 || item_count=item_count_with_yp, 
    "OK", 
    "NOT OK"
)

这是示例输出-