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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
waleed111
Helper V
Helper V

text to date converting

when i write this formula:

sales year = FORMAT('Purchase Order Received Report'[Added Time], "yyyy")
then use it as date type it show me this error:
Cannot convert value '2020' of type Text to type Date.
how to fix this problem?
1 ACCEPTED SOLUTION
Anonymous
Not applicable

HI @waleed111,

So you mean you want to change the date type field to only display the year values? If this is a case, I'd like to suggest you take a look at the following link about table properties text formatting which only changes the disabled format and keeping raw field values.

Use custom format strings in Power BI Desktop 

Notice: format function will return text values with the custom format as you defined in the optional parameter.
Regards,

Xiaoxin Sheng

View solution in original post

4 REPLIES 4
Anonymous
Not applicable

HI @waleed111,

So you mean you want to change the date type field to only display the year values? If this is a case, I'd like to suggest you take a look at the following link about table properties text formatting which only changes the disabled format and keeping raw field values.

Use custom format strings in Power BI Desktop 

Notice: format function will return text values with the custom format as you defined in the optional parameter.
Regards,

Xiaoxin Sheng

amitchandak
Super User
Super User

@waleed111 , what is data in 'Purchase Order Received Report'[Added Time]

This error can come if [Added Time] has only year no date.

Or you are trying to change data type of the column to date

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

yes i try to change data type of the column to date

@waleed111

The FORMAT function in DAX converts your data to Text. Because you're using "YYYY" you could choose to convert this to a Number data type, but it is no longer a Date. You need more information to create a Date type. Just keep the Year column as Text, and keep the date in a separate column.

Please @mention me in your reply if you want a response.

Copying DAX from this post? Click here for a hack to quickly replace it with your own table names

Has this post solved your problem? Please Accept as Solution so that others can find it quickly and to let the community know your problem has been solved.
If you found this post helpful, please give Kudos C

I work as a Microsoft trainer and consultant, specialising in Power BI and Power Query.
www.excelwithallison.com

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.