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

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more

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
Resident Rockstar
Resident Rockstar

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
Resident Rockstar
Resident Rockstar

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
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

60 days of Data Days Carousel

Data Days 2026

Join Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.

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.

Top Solution Authors