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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
Imposed
Frequent Visitor

Change information in a cell to match the rest

2022-09-17 12_39_46-Untitled - Power Query Editor.jpg

 

How do i change the YYYY-MM-DD format shown in the picture to match the YYYYMM format also shown in the picture?

 

Thanks

1 ACCEPTED SOLUTION
ppm1
Solution Sage
Solution Sage

You can transform the column twice to get your result. The first to replace the "-" with "" and the second to extract the first 6 characters.

 

Here's an example. To see how it works, just create a blank query, open the Advanced Editor and replace the text there with the M code below.

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjIwMtI1MNQ1MjJQitWB8A2MlGJjAQ==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Column1 = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Column1", type text}}),
    #"Replaced Value" = Table.ReplaceValue(#"Changed Type","-","",Replacer.ReplaceText,{"Column1"}),
    #"Extracted First Characters" = Table.TransformColumns(#"Replaced Value", {{"Column1", each Text.Start(_, 6), type text}})
in
    #"Extracted First Characters"

 

Pat

 

Microsoft Employee

View solution in original post

1 REPLY 1
ppm1
Solution Sage
Solution Sage

You can transform the column twice to get your result. The first to replace the "-" with "" and the second to extract the first 6 characters.

 

Here's an example. To see how it works, just create a blank query, open the Advanced Editor and replace the text there with the M code below.

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjIwMtI1MNQ1MjJQitWB8A2MlGJjAQ==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Column1 = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Column1", type text}}),
    #"Replaced Value" = Table.ReplaceValue(#"Changed Type","-","",Replacer.ReplaceText,{"Column1"}),
    #"Extracted First Characters" = Table.TransformColumns(#"Replaced Value", {{"Column1", each Text.Start(_, 6), type text}})
in
    #"Extracted First Characters"

 

Pat

 

Microsoft Employee

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.

Top Kudoed Authors