Route217
Route217

Reputation: 43

Nested IF function for OR logic

I cannot seem to see what I am doing wrong with the following nested IF formula...

internet search

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
        )
    )
)

the ability to use or with 3 conditions

Upvotes: 0

Views: 76

Answers (1)

Alexis Olson
Alexis Olson

Reputation: 40244

You can use the OR operator || like this and you don't need nesting:

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
)

You could also use a SWITCH function to avoid nesting:

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
)

Upvotes: 2

Related Questions