Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

Whole Number to Date

Hi, 

My data of order date change from Date to Whole Number when I imported into Power BI. 

Here is the picture for illustration:

numbe to date.PNG

 

Please help me!

I also tried the fomular in other posts, but it did not work!! 

Thanks!! 

2 ACCEPTED SOLUTIONS
Anonymous
Not applicable

in Power Query after you imported the table you will see "Change Type" under applied steps. Power Query tries (and does a pretty good job) at guessing at what your data types are.  Remove that step and see if you can set your date columns to date. If that errors that means there is something in that column that is preventing it from being converted to a date.

View solution in original post

alexvc
Resolver I
Resolver I

Hi there,

 

From what I see, from your data source your date is formatted as string or integer, that's why its not beign recognized as date. What you can do is in the query editor split that column into a day, month and year columns. Then create another column with the formula =DATE(DAY,MONTH,YEAR), this will give you the correct formatted field.

 

In the main ribbon go to Edit Queries. Once in the Power Query Editor, select the column to transform, go to the "Transform" tab, then "Split Column" and choose "By number of characters". In the first step the number of characters will be 4, as all of your years have 4 digits, select the option "Once, as far right as possible". This will leave you with two columns, one with the year and the other one with day + month. Choose the day + month column and do the same, but this time the number of characters has to be 2 (digits in your month). After this you will have the three columns I mentioned in the first paragraph and you can create the new column

 

Let me know if it works

 

Alejandro

 

 

View solution in original post

4 REPLIES 4
alexvc
Resolver I
Resolver I

Hi there,

 

From what I see, from your data source your date is formatted as string or integer, that's why its not beign recognized as date. What you can do is in the query editor split that column into a day, month and year columns. Then create another column with the formula =DATE(DAY,MONTH,YEAR), this will give you the correct formatted field.

 

In the main ribbon go to Edit Queries. Once in the Power Query Editor, select the column to transform, go to the "Transform" tab, then "Split Column" and choose "By number of characters". In the first step the number of characters will be 4, as all of your years have 4 digits, select the option "Once, as far right as possible". This will leave you with two columns, one with the year and the other one with day + month. Choose the day + month column and do the same, but this time the number of characters has to be 2 (digits in your month). After this you will have the three columns I mentioned in the first paragraph and you can create the new column

 

Let me know if it works

 

Alejandro

 

 

Anonymous
Not applicable

Dear, 

I just tried it. 

I works also, both you solution and the other's one. 

Thanks for spending time to help me!! 

Anonymous
Not applicable

in Power Query after you imported the table you will see "Change Type" under applied steps. Power Query tries (and does a pretty good job) at guessing at what your data types are.  Remove that step and see if you can set your date columns to date. If that errors that means there is something in that column that is preventing it from being converted to a date.

Anonymous
Not applicable

Hi ,

Thank you for your solution. I deleted the changed type step and transfrom it to date. 

It works perfectly

Thanks for spending time to help!! 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.