Forum Discussion

domtrump's avatar
domtrump
Icon for Helper II rankHelper II
3 years ago
Solved

CASE Statement replacement for DAX

I don't know when/if the CASE syntax will ever be a part of DAX but I was just wondering if there is a better approach than nested, upon nested, upon nested inline IF syntax? Sure, for very simple th...
  • djurecic's avatar
    3 years ago

    Hi domtrump ,

     I think Switch is what a lot of people use. If the calculations are cluttering up the formula, you might consider using variables to separate those from the switch statement- something like below:

     

    Measure =
    VAR ComplexCondition1 = longcomplexformula1
    VAR ComplexResult2 = longcomplexformula2
    RETURN
        SWITCH ( TRUE (), [ComplexCondition1], [ComplexResult1] )

    etc...