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

Vote for your favorite vizzies from the Power BI Dataviz World Championship submissions. Vote now!

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
Power BI DataViz World Championships

Power BI Dataviz World Championships

Vote for your favorite vizzies from the Power BI World Championship submissions!

Sticker Challenge 2026 Carousel

Join our Community Sticker Challenge 2026

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

January Power BI Update Carousel

Power BI Monthly Update - January 2026

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

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.