用于OR逻辑的嵌套IF函数

时间:2019-06-13 18:26:46

标签: powerbi dax

我似乎看不到下面的嵌套IF公式在做错什么...

互联网搜索

IF (
    SEARCH (
        "compontentdissociation",
        'njrew_k_prmry_bicon_outcm'[INDREV_SUMMARYREVISIONREASONS],
        1,
        1000
    ) <> 1000,
    18,
    IF (
        SEARCH (
            "dislocation subluxation",
            'njrew_k_prmry_bicon_outcm'[INDREV_SUMMARYREVISIONREASONS],
            1,
            1000
        ) <> 1000,
        18,
        IF (
            SEARCH (
                "Prosthesis Dislocation",
                'njrew_k_prmry_bicon_outcm'[INDREV_SUMMARYREVISIONREASONS],
                1,
                1000
            ) <> 1000,
            18
        )
    )
)

使用或在3种条件下使用的能力

1 个答案:

答案 0 :(得分:2)

您可以像这样使用OR运算符||,并且不需要嵌套:

IF (
    SEARCH (
        "compontentdissociation",
        'njrew_k_prmry_bicon_outcm'[INDREV_SUMMARYREVISIONREASONS],
        1,
        1000
    ) <> 1000
        || SEARCH (
            "dislocation subluxation",
            'njrew_k_prmry_bicon_outcm'[INDREV_SUMMARYREVISIONREASONS],
            1,
            1000
        ) <> 1000
        || SEARCH (
            "Prosthesis Dislocation",
            'njrew_k_prmry_bicon_outcm'[INDREV_SUMMARYREVISIONREASONS],
            1,
            1000
        ) <> 1000,
    18
)

您还可以使用SWITCH函数来避免嵌套:

SWITCH (
    TRUE (),
    SEARCH (
        "compontentdissociation",
        'njrew_k_prmry_bicon_outcm'[INDREV_SUMMARYREVISIONREASONS],
        1,
        1000
    ) <> 1000, 18,
    SEARCH (
        "dislocation subluxation",
        'njrew_k_prmry_bicon_outcm'[INDREV_SUMMARYREVISIONREASONS],
        1,
        1000
    ) <> 1000, 18,
    SEARCH (
        "Prosthesis Dislocation",
        'njrew_k_prmry_bicon_outcm'[INDREV_SUMMARYREVISIONREASONS],
        1,
        1000
    ) <> 1000, 18
)