Forum Discussion

IvanCM's avatar
IvanCM
Frequent Visitor
7 years ago
Solved

Duplicate table with every combination based on a specific column

I have an exisiting table where I need to populate missing rows with no values as per the Current and Required table example below... Basically, for every entry, there should be every version of the...
  • Zubair_Muhammad's avatar
    7 years ago

    IvanCM 

     

    Try this.

    Pivot the Timesheet Column using Hours as values ("Dont Aggregate")

    replace nulls with zero

    Unpivot the Actuals and planned columns

     

    Please see attached file for steps

     

    let
        Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjDU9UrM0zW0VNJRcgTh5JLSxJxiIMtCKVYHUz4gJzEvLzUFyLKEyBsh5J1Q9BsaYBjgTMACZ3QLYgE=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [Date = _t, Name = _t, Timesheet = _t, Hours = _t]),
        #"Changed Type" = Table.TransformColumnTypes(Source,{{"Date", type date}, {"Name", type text}, {"Timesheet", type text}, {"Hours", Int64.Type}}),
        #"Pivoted Column" = Table.Pivot(#"Changed Type", List.Distinct(#"Changed Type"[Timesheet]), "Timesheet", "Hours"),
        #"Replaced Value" = Table.ReplaceValue(#"Pivoted Column",null,0,Replacer.ReplaceValue,{"Planned"}),
        #"Unpivoted Columns" = Table.UnpivotOtherColumns(#"Replaced Value", {"Date", "Name"}, "Attribute", "Value")
    in
        #"Unpivoted Columns"