Forum Discussion

faruux6's avatar
faruux6
Regular Visitor
8 years ago
Solved

Convert Number to Date

hey   So I have a following issue: I want to convert a column which includes numbers like "1995", "2000" and "2005" to date (YYYY). How can I do that.    thanks for your help
  • v-piga-msft's avatar
    8 years ago

    Hi faruux6,

     

    By my tests, you could change the data tyoe in Query Editor.

     

    1. Go to Query Editor and change the column type from number to text, then change the text type to date. 

     

    You should note that when you have a remind, you should select the add a new step. Then you will get the data type.

     

    2. Close && Apply. Go to Power BI Data view and click the column and change the data format of the column to 2001(YYYY).

     

    Hope this can help you!

     

    Best Regards,

    Cherry

  • Anonymous's avatar
    Anonymous
    8 years ago

    My recommendation is to do it explictally as part of the Edit Query.  If you have a column that contains only a Year Value, create a new column (Add Column -> Custom Column) called "YearStartDate".  The formula in the UI box should be:

    = Date.FromText(Number.ToText([Year]) & "-01-01")

    This will tell Power BI that you want a date value of that given year, as 1st January.  From here you can format the data as type Date.  Then use the formatting suggestion of v-piga-msft