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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends September 15. Request your voucher.

Reply
Anonymous
Not applicable

Format date from text

I have a column that has years in YYYY text format. I want to convert it to date format (YYYY)

Here are the steps that I carried out:

1. I change the data type of the column to text. Let's call this OldYearColumn

2. I create a custom column and name it as NewYearColumn

3. I use the formula Date.FromText[OldYearColumn]

 

It gives me this error:

Expression.Error: We cannot apply field access to the type Function.
Details:
Value=Function
Key=OldYearColumn

 

I also tried this formula: Date.FromText(Text.From[OldYearColumn]) but this also gives me the same error. Please help.

1 ACCEPTED SOLUTION

Hi @Anonymous 

If your year column is of text type like 2017, 2018, 2019,

just convert the data type to number.

You could use it in the x-axis of a chart.

Capture5.JPGCapture6.JPG

 

If you want to create a column like 2017/1/1, 2018/1/1, 2019/1/1

Just add a custom column

Text.Combine({Text.From([year], "en-US"), "1/1"}, "/")

Then convert the data type to date.

 

Capture7.JPG

 

 

Best Regards
Maggie

 

Community Support Team _ Maggie Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

6 REPLIES 6
Anonymous
Not applicable

@Anonymous  - I don't think you can convert a year to date format. Why does it need to be in date format?

I hope this helps. If it does, please Mark as a solution.
I also appreciate Kudos.
Nathan Peterson
Anonymous
Not applicable

@Anonymous  it needs to be in YYYY format because the cell values are results from a test that is done once every year.

Anonymous
Not applicable

It is already in YYYY format, so I don't understand what else you want to do?

Anonymous
Not applicable

@Anonymous  I should have been more clear. Currently, the date is in text format. I would like to convert it into YYYY date format and build bar graphs with x-axis as years 2013, 2014, 2015,....

Hi @Anonymous 

If your year column is of text type like 2017, 2018, 2019,

just convert the data type to number.

You could use it in the x-axis of a chart.

Capture5.JPGCapture6.JPG

 

If you want to create a column like 2017/1/1, 2018/1/1, 2019/1/1

Just add a custom column

Text.Combine({Text.From([year], "en-US"), "1/1"}, "/")

Then convert the data type to date.

 

Capture7.JPG

 

 

Best Regards
Maggie

 

Community Support Team _ Maggie Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Anonymous
Not applicable

@Anonymous - Date data type requires a year, month and day. Do you want to assign a particular day and month, or are you only interested in the year? When you have a date data type, you can format to only show the year, but a year alone is not a date data type. 

All that said, I think the chart should look just fine with the field just as it is. Could you share a screenshot of your chart and describe how you would like it to be different?

I hope this helps. If it does, please Mark as a solution.
I also appreciate Kudos.
Nathan Peterson

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

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