Pivot tables - Consildating payments into one

24parmar2

New Member
Joined
Feb 15, 2019
Messages
5
Hi everyone,

I'm new to this forum. I need some help with pivot tables:

I'm trying to consolidate payments Ids together, specifically payments which have the same ID but different payments need to be combines and totalled into one. I done a head-start with pivot tables.

I comparing and combining payments from two different tables. If i do a pivot table from each table (C1 and C2) separately it works but i need to match the ID together and calculate the difference as some payment id will be in both tables, this i don;t know how to do quickly or efficiently. This is small example so ID's in C1 don't appear in C2.

The alternative I tried, was using the data range of both tables but the payments ID from C2 would be appeared to be in different format. It has the - icon by it allowing you to expand or collapse that ID, why is it doing for some payments and not all. I am so confused in getting this to work.

Could some one please help me out.

Payment ID (C1)Amount (C1)Payment ID (C2)Amount (C2)
604101275934.360496218539.165
6041012764146.3604962185239.9925
6041012764146.360496218644.76
6041012777253.15604962186261.81
6041012777253.1560496306694.5425
6041012778253.15604963066241.7175
6041012808252.960496306794.5425
6041012809258.74604963067196.3575
6041012876152.8960496306839.165
6041012877263.56604963068116.3825
6041012877328.35604963068145.45
6041012878258.7460496307042.51
6041012879142.96604963070127.53
6041012880252.93604963070141.7
6041012881146.3604963683184.21
6041012881146.360496368414.17
604101288273.1560496368469.76

<colgroup><col><col><col><col></colgroup><tbody>
</tbody>


Thank You
 
downolad and open file I gave you

Data - Show Queries
double click on any table there it will open PowerQuery window
then on the left side unfold Queries click on any and you'll see on the right side steps
you can edit each steps if you see little gear on the end of the step or you can open Advanced Editor from the ribbon to see M-code

for each table is a different M-code that's why I posted link to the file
 
Last edited:
Upvote 0

Excel Facts

What do {} around a formula in the formula bar mean?
{Formula} means the formula was entered using Ctrl+Shift+Enter signifying an old-style array formula.
for the first table (C1)
Code:
[SIZE=1]let
    Source = Excel.CurrentWorkbook(){[Name="tblC1"]}[Content],
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Payment ID (C1)", Int64.Type}, {"Amount (C1)", type number}}),
    #"Grouped Rows" = Table.Group(#"Changed Type", {"Payment ID (C1)"}, {{"Value (C1)", each List.Sum([#"Amount (C1)"]), type number}})
in
    #"Grouped Rows"[/SIZE]
for the second table (C2)
Code:
[SIZE=1]let
    Source = Excel.CurrentWorkbook(){[Name="tblC2"]}[Content],
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Payment ID (C2)", Int64.Type}, {"Amount (C2)", type number}}),
    #"Grouped Rows" = Table.Group(#"Changed Type", {"Payment ID (C2)"}, {{"Value (C2)", each List.Sum([#"Amount (C2)"]), type number}})
in
    #"Grouped Rows"[/SIZE]
for the result table
Code:
[SIZE=1]let
    Source = Table.NestedJoin(tblC1,{"Payment ID (C1)"},tblC2,{"Payment ID (C2)"},"tblC2",JoinKind.Inner),
    #"Expanded tblC2" = Table.ExpandTableColumn(Source, "tblC2", {"Payment ID (C2)", "Value (C2)"}, {"Payment ID (C2)", "Value (C2)"}),
    #"Replaced Value" = Table.ReplaceValue(#"Expanded tblC2",null,0,Replacer.ReplaceValue,{"Payment ID (C1)", "Value (C1)", "Payment ID (C2)", "Value (C2)"}),
    #"Inserted Subtraction" = Table.AddColumn(#"Replaced Value", "Subtraction", each [#"Value (C1)"] - [#"Value (C2)"], type number),
    #"Removed Columns" = Table.RemoveColumns(#"Inserted Subtraction",{"Value (C1)", "Value (C2)"}),
    #"Changed Type" = Table.TransformColumnTypes(#"Removed Columns",{{"Payment ID (C1)", type text}, {"Payment ID (C2)", type text}})
in
    #"Changed Type"[/SIZE]
 
Upvote 0

Forum statistics

Threads
1,215,145
Messages
6,123,289
Members
449,094
Latest member
GoToLeep

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top