Forum Discussion

heathernicole's avatar
heathernicole
Icon for Continued Contributor rankContinued Contributor
10 years ago
Solved

How to create an IF statement in Power BI for reporting

 Trying to create an 'IF' statement in DAX.   I'm trying to create a calculated column - if Age of Customer is <= 365 - then display 4000 if it's greater than 365 - display nothing - or 0.    Th...
  • JeffDuzak's avatar
    JeffDuzak
    10 years ago

    Could you double check that you are adding a calc column to the Customer table?  If you are adding a calc column to a different table, then you won't be able to directly refer to a column on the Customer table.

  • JeffDuzak's avatar
    JeffDuzak
    10 years ago

    Could you describe your model a bit more?  Where do you want to define this calculated column?

     

    If you want to define the column in a table that has a many-to-one or one-to-one relationship or path of such relationships to the Customer table, then you *can* refer to columns in the Customer table, but you just have to wrap the reference in a call to the RELATED function.  So, it would look like:

     

    New Customer Pts = IF(RELATED(Customer[Age of Customer (in Days)]) <= 365, 4000, 0)