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

Level up your Power BI skills this month - build one visual each week and tell better stories with data! Get started

Reply
PPStar
Helper V
Helper V

Format Date Column

Hello. 

I have a dataflow in the power BI Service. There is a date column (Date) which needs to be as a text data type (dont ask why) and needs to be in a specific format. 

Currently the date column is in the dd/mm/yyyy format. 

I need to change this so its in the yyyy-MM-dd format , but as a string. 

 

I have added the following code

Text.From([#"Date"], "yyyy-MM-dd", "en-US"
 
and i get the following error : 
 
Expression.Error: 3 arguments were passed to a function which expects between 1 and 2.
Details
Reason = Expression.Error
Arguments = {#date(2015, 6, 21), "yyyy-MM-dd", "en-US"}
 
WHat am i doing wrong?

 

1 ACCEPTED SOLUTION

Try this: Table.TransformColumns(Navigation, {{"YYYY-MM-DD", each Date.ToText(_, "yyyy-MM-dd"), type text}}) and see if this solves your problem





Did I answer your question? Mark my post as a solution! Kudos are welcome.

Proud to be a Super User!




View solution in original post

8 REPLIES 8
_AAndrade
Super User
Super User

Yes it's possible. Please try this:

Table.TransformColumns(Navigation, {[#"Date"], each Date.ToText(_, "yyyy-MM-dd")})

Instead of "Table.AddColumn(Navigation, "Custom", each Date.ToText([#"Date"], "yyyy-MM-dd"))"

 





Did I answer your question? Mark my post as a solution! Kudos are welcome.

Proud to be a Super User!




Whilst visually, this looks correct, i just tried it and it gives me this error : 

 

Expression.Error: There is an unknown identifier. Did you use the [field] shorthand for a _[field] outside of an 'each' expression?

Details
Reason = Expression.Error
 
Any ideas

I use tha name of my column Date where I want to transform.
Probably the error is on the [#"Date"]. Replace this column name for your column date name.

 





Did I answer your question? Mark my post as a solution! Kudos are welcome.

Proud to be a Super User!




I did that. My date column is called Y-M-D.

 

This is the code i am using 

 

 #"Custom Column" = Table.TransformColumns(Navigation, {[#"Y-M-D"], each Date.ToText(_, "yyyy-MM-dd")})

Try this: Table.TransformColumns(Navigation, {{"YYYY-MM-DD", each Date.ToText(_, "yyyy-MM-dd"), type text}}) and see if this solves your problem





Did I answer your question? Mark my post as a solution! Kudos are welcome.

Proud to be a Super User!




Thank you so much. That worked

_AAndrade
Super User
Super User

Hi,

Try this code:

Date.ToText([Date], "yyyy-MM-dd")




Did I answer your question? Mark my post as a solution! Kudos are welcome.

Proud to be a Super User!




Thanks. That worked. 

 

Do you know how i can alter the existing M code - so we dont create a new column

 

At the moment i have this M code

 

  #"Added custom" = Table.AddColumn(Navigation, "Custom", each Date.ToText([#"Date"], "yyyy-MM-dd")),
  #"Transform columns" = Table.TransformColumnTypes(#"Added custom", {{"Custom", type text}})
 
This create a new column called Custom. Whilst this works. I want to acheive the same without creating a new column
Can we just modify the existing column to ensure its in yyyy-MM-dd format and as text?

 

Helpful resources

Announcements
April Power BI Update Carousel

Power BI Monthly Update - April 2026

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

Fabric SQL PBI Data Days

Data Days 2026 coming soon!

Sign up to receive a private message when registration opens and key events begin.

New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.