Forum Discussion

Jonas_'s avatar
Jonas_
New Member
4 years ago
Solved

Combining tables analytical accounting

Hello,   I have 3 different tables: The first is from the classical accounting.   Booking reference Amount …   251 € 100.00 252 € 150.00 253 € 400.00 ...
  • AlexisOlson's avatar
    4 years ago

    Merge the 2nd and 3rd table into the first one, expanding the cost and percentage columns from each, and then define a new custom column that multiplies the percentages with the initial amount.

     

    let
        Source = Centers,
        #"Grouped Rows" = Table.Group(Source, {"Booking reference"}, {{"Amount", each List.Sum([Amount]), type nullable number}}),
        #"Merged Queries" = Table.NestedJoin(#"Grouped Rows", {"Booking reference"}, Centers, {"Booking reference"}, "Centers", JoinKind.LeftOuter),
        #"Expanded Centers" = Table.ExpandTableColumn(#"Merged Queries", "Centers", {"Cost center", "Percentage"}, {"Cost center", "Center%"}),
        #"Merged Queries1" = Table.NestedJoin(#"Expanded Centers", {"Booking reference"}, Places, {"Booking reference"}, "Places", JoinKind.LeftOuter),
        #"Expanded Places" = Table.ExpandTableColumn(#"Merged Queries1", "Places", {"Cost place", "Percentage"}, {"Cost place", "Place%"}),
        #"Added Custom" = Table.AddColumn(#"Expanded Places", "Custom", each [#"Center%"] * [#"Place%"] * [Amount], type number)
    in
        #"Added Custom"

     

     

    See the attached file.