Forum Discussion

tomekm's avatar
tomekm
Helper III
1 year ago
Solved

Multiple nested IF statements

Hello,   I'm trying to write a dax formula for a calculated column that contains multiple IF statements but I'm getting stuck with syntax errors. This is how the formula looks like in excel, but it...
  • SamsonTruong's avatar
    1 year ago

    Hi tomekm ,

    Please try the following DAX for your calculated column and replace 'Table' with the name of your table:

    Status = 
    IF (
        'Table'[Total] > 0,
        SWITCH (
            TRUE(),
            'Table'[A] > 0 && 'Table'[B] > 0 && 'Table'[C] > 1 && 'Table'[D] > 1,
                IF('Table'[Customer Type] = "OK", "Primary", "Secondary"),
            'Table'[A] > 0 && 'Table'[C] > 1 && 'Table'[D] > 0,
                IF('Table'[Customer Type] = "Upcoming", "Tertiary", "Advanced"),
            'Table'[Customer Type] = "Other", "Basic",
            "Next"
        ),
        "No Access"
    )

      
    The SWITCH() function in DAX acts the same as nested IF() statements. However, it is more performant and easier to manage.

    If this helped, please mark it as the solution so others can benefit too. And if you found it useful, kudos are always appreciated.

    Thanks,

    Samson