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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

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

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.