Wednesday, October 26, 2022

Power Query - Create Rows Interval Dates (TO - FROM )

 let

    Source = DIM_SAP_Centro_CustoTXT,

    #"Changed Type1" = Table.TransformColumnTypes(Source,{{"DATEFROM", type date}, {"DATETO", type date}}),

    #"Added Custom" = Table.AddColumn(#"Changed Type1", "Custom", each List.Dates([DATEFROM], Number.From([DATETO]-[DATEFROM])+1, #duration(1, 0, 0, 0))),

    #"Expanded Custom" = Table.ExpandListColumn(#"Added Custom", "Custom"),

    #"Changed Type2" = Table.TransformColumnTypes(#"Expanded Custom",{{"Custom", type text}}),

    #"Filtered Rows" = Table.SelectRows(#"Changed Type2", each Text.StartsWith([Custom], "01")),

    #"Added Custom Column" = Table.AddColumn(#"Filtered Rows", "AnoMes", each Text.Combine({Date.ToText(Date.From([Custom]), "yyyy"), Date.ToText(Date.From([Custom]), "MM")}), type text),

    #"Removed Other Columns" = Table.SelectColumns(#"Added Custom Column",{"AnoMes", "COSTCENTER", "TXTSH", "DATETO", "DATEFROM"})

in

    #"Removed Other Columns"

No comments:

Post a Comment

Power BI APP - Delete or Unpublish

 UNPUBLISH DELETE