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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
jcastr02
Post Prodigy
Post Prodigy

m code for "mmm-yy"

Hello,

 

I am trying to create a custom column to convert a date to format  "mmm-yy"  using m code?

1 ACCEPTED SOLUTION
Jimmy801
Community Champion
Community Champion

Hello @jcastr02 

 

you can use Date.ToText(Date,"MMM-yy"). Here an example where I added a new column to make the transformation you need

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjDUAyIjA6VYHTjHEMwxsoBxYgE=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Date = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Date", type date}}, "de-DE"),
    #"Added Custom" = Table.AddColumn(#"Changed Type", "Custom", each Date.ToText(_[Date], "MMM-yy"))
in
    #"Added Custom"

Jimmy801_0-1609784707934.png

 

Copy paste this code to the advanced editor in a new blank query to see how the solution works. 

If this post helps or solves your problem, please mark it as solution (to help other users find useful content and to acknowledge the work of users that helped you)
Kudoes are nice too

Have fun

Jimmy

View solution in original post

1 REPLY 1
Jimmy801
Community Champion
Community Champion

Hello @jcastr02 

 

you can use Date.ToText(Date,"MMM-yy"). Here an example where I added a new column to make the transformation you need

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjDUAyIjA6VYHTjHEMwxsoBxYgE=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Date = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Date", type date}}, "de-DE"),
    #"Added Custom" = Table.AddColumn(#"Changed Type", "Custom", each Date.ToText(_[Date], "MMM-yy"))
in
    #"Added Custom"

Jimmy801_0-1609784707934.png

 

Copy paste this code to the advanced editor in a new blank query to see how the solution works. 

If this post helps or solves your problem, please mark it as solution (to help other users find useful content and to acknowledge the work of users that helped you)
Kudoes are nice too

Have fun

Jimmy

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.

Top Solution Authors