Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
4 years ago
Solved

Return value of column

Hi, I am new to Powerbi and I am finding it difficult to fine a DAX formula that works for what I want to do.

 

If column Y has a date in the column ignore column X, if column Z has a date in the column ignore column Y. If there is no date in column Zand Y return column X. Thank you for your help in advance 

 

Column X Column Y  Column Z 
22/01/2021 25/03/2021

 

28/08/2021

     
     
  • Hi Anonymous ,

     

    In DAX it would be something like this:

    _myDate =
    SWITCH(
      TRUE(),
      NOT ISBLANK(yourTable[Column Z]), yourTable[Column Z],
      NOT ISBLANK(yourTable[Column Y]), yourTable[Column Y],
      yourTable[Column X]
    )

     

    In Power Query, you could do something like this:

    List.Last(ListRemoveNulls({[Column X], [Column Y], [Column Z]}))

     

    There's more than one way to achieve this in either DAX or Power Query though.

     

    Pete

2 Replies

  • Hi Anonymous ,

     

    In DAX it would be something like this:

    _myDate =
    SWITCH(
      TRUE(),
      NOT ISBLANK(yourTable[Column Z]), yourTable[Column Z],
      NOT ISBLANK(yourTable[Column Y]), yourTable[Column Y],
      yourTable[Column X]
    )

     

    In Power Query, you could do something like this:

    List.Last(ListRemoveNulls({[Column X], [Column Y], [Column Z]}))

     

    There's more than one way to achieve this in either DAX or Power Query though.

     

    Pete

    • Anonymous's avatar
      Anonymous
      Not applicable

      It worked! thank you so much 🙂