Forum Discussion

JCortez's avatar
JCortez
Frequent Visitor
1 year ago
Solved

Copy only Date Values into New Column

I have a column which has dates and other values (answers to questions). Is it possible to create a new column only copying the date values and excluding the other data? If so, how can I do this?

Thank you in advanced.
Javier

  • Hi JCortez 

    You can create a new column in DAX that keeps only the date values and returns blank for anything else using this code

     

    DateOnlyColumn = 
    IF (
    ISBLANK([YourColumn]),
    BLANK(),
    IF (
    NOT(ISERROR(DATEVALUE([YourColumn]))),
    DATEVALUE([YourColumn]),
    BLANK()
    )
    )

     

    Did it work? πŸ‘ A kudos would be appreciated
    🟨 Mark it as a solution to help spread knowledge πŸ’‘

     

    🟩 Follow me on LinkedIn

9 Replies

    • JCortez's avatar
      JCortez
      Frequent Visitor

      I would like just the date values copied from the column named Response to the New Column Response (Copy). The non date values can be left blank.

      • DataVitalizer's avatar
        DataVitalizer
        Super User

        Hi JCortez 

        You can create a new column in DAX that keeps only the date values and returns blank for anything else using this code

         

        DateOnlyColumn = 
        IF (
        ISBLANK([YourColumn]),
        BLANK(),
        IF (
        NOT(ISERROR(DATEVALUE([YourColumn]))),
        DATEVALUE([YourColumn]),
        BLANK()
        )
        )

         

        Did it work? πŸ‘ A kudos would be appreciated
        🟨 Mark it as a solution to help spread knowledge πŸ’‘

         

        🟩 Follow me on LinkedIn

  • It would be good if yo provided a sample as Solution Sage mention as it may vary.  You can use the Split Column option during the transformation process by highlighting the column and use some type of deliminator.

     

  • Can you add a conditional column that if you have a backlash / then it would select the date on new column.  I understand you might have other text with / might have to add and additional logic if you do.