Forum Discussion

tuncay's avatar
tuncay
Helper III
1 year ago
Solved

Power Query: Remove day from date month

I have a date column showing the date in that format: DD.MM.YYYY But I only want to have that in that format MM.YYYY without losing the type date.   How can I do that?
  • bhanu_gautam's avatar
    1 year ago

    tuncay , Try using below m - code

    let
    Source = ... , // Your data source here
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"DateColumn", type date}}),
    #"Added Month" = Table.AddColumn(#"Changed Type", "Month", each Date.Month([DateColumn]), Int64.Type),
    #"Added Year" = Table.AddColumn(#"Changed Type", "Year", each Date.Year([DateColumn]), Int64.Type),
    #"Added Custom" = Table.AddColumn(#"Added Year", "MonthYear", each Text.PadStart(Text.From([Month]), 2, "0") & "." & Text.From([Year]), type text),
    #"Removed Columns" = Table.RemoveColumns(#"Added Custom",{"DateColumn", "Month", "Year"})
    in
    #"Removed Columns"