Forum Discussion

bobceres's avatar
bobceres
Regular Visitor
4 years ago
Solved

IF THEN ELSE

I am familiar with IF THEN ELSE statements in excel, but not sure how it translates to DAX.  Essentially I have a column with several 6 digits numbers, but some of the values in that column are blank.  I want build a new custom column with an IF THEN ELSE statement that states IF that column is blank, to use the values of another column. IF it is not blank, it keeps the current value.

 

  • Hi, bobceres 

    According to your description, I can roughly understand your requirement, I think you can create a calculated column like this to achieve your requirement:

    This is my test data:

    Expected ID =
    
    IF(ISBLANK([ID1]),[ID2],[ID1])

     

    And you can get what you want, like this:

     

    You can download my test pbix file below

    Thank you very much!

     

    Best Regards,

    Community Support Team _Robert Qin

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

3 Replies

  • v-robertq-msft's avatar
    v-robertq-msft
    Icon for Community Support rankCommunity Support

    Hi, bobceres 

    According to your description, I can roughly understand your requirement, I think you can create a calculated column like this to achieve your requirement:

    This is my test data:

    Expected ID =
    
    IF(ISBLANK([ID1]),[ID2],[ID1])

     

    And you can get what you want, like this:

     

    You can download my test pbix file below

    Thank you very much!

     

    Best Regards,

    Community Support Team _Robert Qin

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

  • mahoneypat's avatar
    mahoneypat
    Icon for Microsoft Employee rankMicrosoft Employee

    If the blank values are showing as null, you can use this expression.  If they don't, you can use = "" instead.

     

    = if [columnwithvalue] = null then [othercolumn] else [columnwithvalue]

     

    Pat

  • Hi bobceres 

     

    You need to use IF and ISBLANK dax functions:

    something like this:

     

    If(isblank([column1]),[column2],[column1])

    If this post helps, please consider accepting it as the solution to help the other members find it more quickly.

    Appreciate your Kudos!!