Forum Discussion

pl456's avatar
pl456
Regular Visitor
6 years ago
Solved

Copying a table change the datatype

Hi, I've found a weird behavior in PBI Desktop :

If I create a new table from scratch with a date column like so :


And I copy this table using DAX :

The newly created table will have the date column type as Date/time instead of Date like the original table :


Is that behaviour by design? Any way around this?

Thanks for the help.

  • Hi pl456 

     

    This isn't a bug but a difference in how dates are handled between DAX and Power BI.

    DAX only has the DateTime data type to handle dates. In Power BI, there are two additional data type: Date and Time.

    See here for more info: dax.guide/dt/datetime/ 

     

    Because you're using DAX to create your new table, the data type is forced to DateTime.

     

    Once you've created your new table, you can simply change the data type of the column using the UI in Power BI.

     

    Hope this helps.

     

    Best regards,
    Martyn


    If I answered your question, please help others by accepting it as a solution.

2 Replies

  • Hi pl456 

     

    This isn't a bug but a difference in how dates are handled between DAX and Power BI.

    DAX only has the DateTime data type to handle dates. In Power BI, there are two additional data type: Date and Time.

    See here for more info: dax.guide/dt/datetime/ 

     

    Because you're using DAX to create your new table, the data type is forced to DateTime.

     

    Once you've created your new table, you can simply change the data type of the column using the UI in Power BI.

     

    Hope this helps.

     

    Best regards,
    Martyn


    If I answered your question, please help others by accepting it as a solution.

    • pl456's avatar
      pl456
      Regular Visitor

      That makes a lot of sense. Thanks for the explanation.