Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
6 years ago

DAX IF Statement

I am new to writing DAX and trying to write the below IF statement:

 

Forecast/Actual= If TableX(actual amount) has a value, use TableX(actual amount) value. If TableX(actual amount) has no value, use Table Y(forecast amount)

 

No value meaning blank or 0.

 

Any help would be greatly appreciated! Thanks in advance

 

 

1 Reply

  • kentyler's avatar
    kentyler
    Icon for Solution Sage rankSolution Sage

    DAX offers the ISBLANK() function that you can use to solve part of your problem.

    VAR replace = OR(IF( ISBLANK(TableX[actual amount]) ,  TableX[actual amount] =0)

    RETURN IF(replace,tabley[forecast amount],tablex[actual amount])

     

    this separates the test for whether or not you want to replace the value by using the OR function, if either of the arguments to OR is true it returns true.

    If replace = true then you return the forecast, otherwise the actual