Forum Discussion

JarekM's avatar
JarekM
Regular Visitor
3 years ago
Solved

Overlay Two Tabel

Hi, I am New maybe someone can help me here I need to overlaay two tabel    I tried to group but got stuck, how to do this using :   #"Aantal samengevoegd" = Table.AggregateTableColumn(#"Rijen g...
  • jennratten's avatar
    jennratten
    3 years ago

    Hello - instead of looping through columns, I think it would be better to append the tables, unpivot, transform and repivot, like this:

    let
        Source = Table.Combine({Table1, Table2}),
        #"Unpivoted Other Columns" = Table.UnpivotOtherColumns(Source, {"Name", "Place"}, "Attribute", "Value"),
        #"Replaced Value" = Table.ReplaceValue(#"Unpivoted Other Columns","",null,Replacer.ReplaceValue,{"Value"}),
        #"Grouped Rows" = Table.Group(#"Replaced Value", {"Name", "Place", "Attribute"}, {{"Data", each _, type table [Name=nullable text, Place=nullable text, Attribute=text, Value=text]}}),
        #"Added Custom" = Table.AddColumn(#"Grouped Rows", "Custom", each if List.NonNullCount ( [Data][Value] ) > 1 then Text.Combine ( List.Sort ( [Data] [Value] ), " - " ) else List.RemoveNulls ( [Data][Value] ){0} ),
        #"Removed Columns" = Table.RemoveColumns(#"Added Custom",{"Data"}),
        #"Pivoted Column" = Table.Pivot(#"Removed Columns", List.Distinct(#"Removed Columns"[Attribute]), "Attribute", "Custom")
    in
        #"Pivoted Column"

    Result