Cross Tab from Accounting Entries Debit Credits

kashifzafar02

New Member
Joined
Jan 28, 2022
Messages
1
Office Version
  1. 365
Platform
  1. Windows
Dear All

I have accounting entries in the following format

Date​
Voucher No​
Party​
Dr/Cr​
Debit Amount​
Credit Amount​
Net​
03-01-22​
1​
A​
Dr​
100​
100​
03-01-22​
1​
B​
Cr​
100​
-100​
03-01-22​
2​
A​
Dr​
40​
40​
03-01-22​
2​
C​
Cr​
40​
-40​
03-01-22​
3​
D​
Dr​
72​
72​
03-01-22​
3​
A​
Cr​
72​
-72​
03-01-22​
4​
A​
Dr​
2​
2​
03-01-22​
4​
A​
Cr​
2​
-2​

Out put I am looking for is:

ABCD
Total​
A
0​
100​
40​
-72​
68​
B
-100​
-100​
C
-40​
-40​
D
72​
72​
Total​
-68​
100​
40​
-72​
0​


Link to file is

I have tried Power query also but cannot get the logic. Any help is appreciated.

Thank you.
 

Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.
As long as your Dr always precedes its corresponding Cr then this may work:

Power Query:
let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    AddIndex = Table.AddIndexColumn(Source, "Index", 0, 1, Int64.Type),
    tbl = Table.AddColumn(AddIndex, "Map", each if [#"Dr/Cr"] = "Dr" then {_[Party], AddIndex[Party]{_[Index]+1}, [Net]} else {_[Party], AddIndex[Party]{_[Index]-1}, [Net]}),
    Map = Table.FromRows(tbl[Map]),
    Group = Table.Group(Map, {"Column1", "Column2"}, {{"Total", each List.Sum([Column3]), type number}}),
    Group1 = Table.Group(Group, {"Column1"}, {{"All", each Table.Sort(_, "Column2")}}),
    tbl1 = Table.AddColumn(Group1, "rows", each {[Column1]} & List.Accumulate(Group1[Column1], {}, (s,c)=> 
            s & (if List.PositionOf([All][Column2],c)>-1 then {_[All][Total]{List.PositionOf(Group1[Column1],c)}} else {null}))),
    tbl2 = Table.FromRows(tbl1[rows], {"Party"} & tbl1[Column1]),
    tbl3 = Table.AddColumn(tbl2,"Total", each List.Sum(List.Skip(Record.ToList(_),1))),
    tcn = Table.ColumnNames(tbl3),
    lst = {"Total"} & List.Accumulate(List.Skip(tcn,1), {}, (s,c)=> s & {List.Sum(Table.Column(tbl3,c))}),
    rcd = Record.FromList(lst, tcn),
    Result = Table.InsertRows(tbl3, Table.RowCount(tbl3), {rcd})
in
    Result

PQ pivot transactions.xlsx
ABCDEFGHIJKLMNO
1DateVoucher NoPartyDr/CrDebit AmountCredit AmountNetPartyABCDTotal
23/1/20221ADr100100A010040-7268
33/1/20221BCr100-100B-100-100
43/1/20222ADr4040C-40-40
53/1/20222CCr40-40D7272
63/1/20223DDr7272Total-6810040-720
73/1/20223ACr72-72
83/1/20224ADr22
93/1/20224ACr2-2
10
Sheet1
 
Upvote 0

Forum statistics

Threads
1,225,492
Messages
6,185,300
Members
453,286
Latest member
JCM

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