Forum Discussion

tcburge3's avatar
tcburge3
Helper I
3 years ago
Solved

DAX command to Status a column based on filtered Rows and IF statements

Hello,   I am running into a problem with writing a column that grabs other row item's statuses.   I have the following data: Script ID Test Outcome 1 Passed 1 Passed 2 Passed ...
  • lukiz84's avatar
    3 years ago

    Hi,

     

    try:

     

    Outcome = 
        VAR ScriptOutcomes =
            CALCULATETABLE(
                VALUES(TableTests[Test Outcome]),
                FILTER(
                    ALL(TableTests),
                    TableTests[Script ID] = EARLIER(TableTests[Script ID])
                )
            )
        
        VAR hasPassed = CONTAINSROW(ScriptOutcomes, "Passed")
        VAR hasFailed = CONTAINSROW(ScriptOutcomes, "Failed")
        VAR isBlocked = CONTAINSROW(ScriptOutcomes, "Blocked")
    
        RETURN 
            IF(
                isBlocked,
                "Blocked",
                IF(
                    hasFailed,
                    "Failed",
                    IF
                        (hasPassed,
                        "Passed",
                        "N/A"
                    )
                )
            )