DAX not performing short-circuit evaluations for the IF function RRS feed

  • Question

  • We are observing that the short circuit evaluations are not being performed for the IF function for DAX. In the query below based off of AdventureWorks we have a measure called test which has a IF function which always evaluates to true (1 > 0). In this case the 1 should be returned and the else expression should not be evaluated. The else expression when executed on its own takes about 20 seconds.  The query below is executing in 20 seconds so it appears both branches of the IF statement are being evaluated.

    MEASURE 'Sales Territory'[test] = IF(1 > 0, 1, SUMX(CROSSJOIN('Product', 'Customer'), [Total Sales]))
    evaluate summarize('Sales Territory', "sales",[Total Sales], "test", [test])

    Even breaking up the if statement into multiple measures resulted in the same behavior:

    MEASURE 'Sales Territory'[test1] = 1
    MEASURE 'Sales Territory'[test2] = SUMX(CROSSJOIN('Product', 'Customer'), [Total Sales])
    MEASURE 'Sales Territory'[test] = IF(1 > 0, [test1],[test2])
    evaluate summarize('Sales Territory', "sales",[Total Sales], "test", [test])

    Based off of this it appears that all of the branches are being evaluated even though only one condition is met. Is there a way to force Analysis Services not to perform the evaluation of the else branch in this case ?


    • Edited by rthar Thursday, September 5, 2013 11:29 PM
    Thursday, September 5, 2013 11:15 PM


All replies