Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
3 years ago
Solved

insertar filas por fechas

Saludo cordial Quisiera saber por medio de Power Query como se puede insertar una fila como la que está en negrilla Es decir, que si la columna dias  tiene un valor mayor a uno se inserte la cantid...
  • v-yanjiang-msft's avatar
    3 years ago

    There Anonymous ,

    According to your description, here's my solution.

    Add a custom column.

    List.Dates([start date],[day],#duration(1, 0, 0, 0))

    Expand the custom column list. 

    Then remove the start date column and rename the custom column to start date, then reorder columns, get the correct result.

    Here's the whole M syntax:

    let
        Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjIwMtK30Dc0UtJBYRsqxepAZQ2N9I0MYdIgDlgtkry+oTlcWt/QEsg2VoqNBQA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"start date" = _t, #"end date" = _t, day = _t]),
        #"Changed Type" = Table.TransformColumnTypes(Source,{{"start date", type date}, {"end date", type date}, {"day", Int64.Type}}),
        #"Added Custom" = Table.AddColumn(#"Changed Type", "Custom", each List.Dates([start date],[day],#duration(1, 0, 0, 0))),
        #"Expanded Custom" = Table.ExpandListColumn(#"Added Custom", "Custom"),
        #"Removed Columns" = Table.RemoveColumns(#"Expanded Custom",{"start date"}),
        #"Renamed Columns" = Table.RenameColumns(#"Removed Columns",{{"Custom", "start date"}}),
        #"Reordered Columns" = Table.ReorderColumns(#"Renamed Columns",{"start date", "end date", "day"})
    in
        #"Reordered Columns"

    I attach my sample below for your reference.

     

    Best Regards,
    Community Support Team _ kalyj

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.