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
Chuky01
Helper I
Helper I

How do I format text column with year to date format in Power BI

I imported a dataset with a data column that was just the year (2005 - 2018). However this column is showing in Power BI as text. I have tried to use the formula (blue area) to change it to date format, however as you can see in the green area the "Year" is not lining up. How do I convert text column to a date. My datapoints are annual so I really only need a "Year" column.

 

 

Capture.PNG

1 ACCEPTED SOLUTION
Anand24
Super User
Super User

Hi @Chuky01 ,

 

Go to Power Query Editor and follow below steps:

1. Right Click on Date Column -> Change Type -> Select "Date"

11.PNG

 

2. Right click again on Date Column -> Transform -> Year -> Year

12.PNG

 

Alternatively, you can only perform step 1 and then pull 'Year' from date hierarchy when creating visualizations:

13.PNG

 

Give a thumbs up if this post helped you in any way and mark this post as solution if it solved your query !!!

View solution in original post

5 REPLIES 5
v-lionel-msft
Community Support
Community Support

Hi @Chuky01 ,

 

Has your problem been solved?

 

Best regards,
Lionel Chen

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

v-lionel-msft
Community Support
Community Support

Hi @Chuky01 ,

 

I have a sample data like this.

v-lionel-msft_0-1597024139781.png

1. Change type of the column in 'Edit Query' and you'll get the values.

v-lionel-msft_1-1597024309932.png

2. Change the format of the column in 'Data View'.

v-lionel-msft_2-1597024388649.png

v-lionel-msft_4-1597024445896.png

 

Best regards,
Lionel Chen

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

mahoneypat
Employee
Employee

If you need/want to do it on the query side (e.g., you have data transformations needing a date column), you can use this formula in a custom column

 

= #date(Number.FromText([Calendar Year]),1,1)

 

If you first convert the Calendar Year to whole number, you won't need the Number.FromText part.

 

If this works for you, please mark it as the solution.  Kudos are appreciated too.  Please let me know if not.

Regards,

Pat





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


Greg_Deckler
Super User
Super User

@Chuky01 - Could you just use:

 

=Date([Calendar Year],1,1)


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...
Anand24
Super User
Super User

Hi @Chuky01 ,

 

Go to Power Query Editor and follow below steps:

1. Right Click on Date Column -> Change Type -> Select "Date"

11.PNG

 

2. Right click again on Date Column -> Transform -> Year -> Year

12.PNG

 

Alternatively, you can only perform step 1 and then pull 'Year' from date hierarchy when creating visualizations:

13.PNG

 

Give a thumbs up if this post helped you in any way and mark this post as solution if it solved your query !!!

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.