Forum Discussion

CincyKJ's avatar
CincyKJ
Frequent Visitor
2 years ago
Solved

Need to Insert Rows for Months between two respective Months listed in the same Date column

Hello Power Query Community!  🙂   Below is a graphic of my current Power Query challenge in Excel:   In my current "Before" table, I have a list of 4 Effective Dates (listed as the first d...
  • Anonymous's avatar
    Anonymous
    2 years ago

    Hi CincyKJ ,

    I suggest you add a calendar table like this one:

    In the Power Query, choose the Before Table, and select Merge Queries:


    Choose column Rate and choose fill down:

    And the final output is as below:

    let
        Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMtQ31DcyMDJW0lEyVYrViVYyQQiYgQUMDRAi5hARiIAJUMBCKTYWAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Effective Date" = _t, Rate = _t]),
        #"Changed Type" = Table.TransformColumnTypes(Source,{{"Effective Date", type date}, {"Rate", Int64.Type}}),
        #"Merged Queries" = Table.NestedJoin(#"Changed Type", {"Effective Date"}, Calendar, {"Date"}, "Calendar", JoinKind.FullOuter),
        #"Expanded Calendar" = Table.ExpandTableColumn(#"Merged Queries", "Calendar", {"Date"}, {"Date"}),
        #"Sorted Rows" = Table.Sort(#"Expanded Calendar",{{"Date", Order.Ascending}}),
        #"Filled Down" = Table.FillDown(#"Sorted Rows",{"Rate"})
    in
        #"Filled Down"


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

  • CincyKJ's avatar
    CincyKJ
    2 years ago

    Hi Dino Tao.

     

    Thank you ever so much.  "Merging Calendars" worked perfectly for me!