Convert horizontal data to vertical with running balance

ExcelNewbie2020

Active Member
Joined
Dec 3, 2020
Messages
350
Office Version
  1. 365
Platform
  1. Windows
have this data arrange horizontally, i would like to convert it vertically together with the name with running balance (total). Also the date should be sorted.. would it be possible using formula?..thanks

Book2
ABCDEFGHIJKLMNO
1NAMEDATEAMTDATEAMTDATEAMTEXPECTED RESULT (FORMULA HERE)
2A9-Oct-20249422-May-20244719-Jun-202433DATENAMEAMTTOTAL
3B30-Sep-20247529-Sep-20248012-Apr-20247112-Apr-24B7171
4C31-Dec-2024251-Dec-20246319-May-20243319-May-24C33104
5D10-Jul-20246025-Jun-20241215-Dec-20245422-May-24A47151
619-Jun-24A33184
725-Jun-24D12196
810-Jul-24D60256
929-Sep-24B80336
1030-Sep-24B75411
1109-Oct-24A94505
1201-Dec-24C63568
1315-Dec-24D54622
1431-Dec-24C25647
15
16
Sheet1
 

Excel Facts

Easy bullets in Excel
If you have a numeric keypad, press Alt+7 on numeric keypad to type a bullet in Excel.
Try this:
Excel Formula:
=LET(
i,A2:G5,
array,SORT(VSTACK(CHOOSECOLS(i,2,1,3),CHOOSECOLS(i,4,1,5),CHOOSECOLS(i,6,1,7)),1),
total,SCAN(0,CHOOSECOLS(array,3),LAMBDA(a,b,a+b)),
HSTACK(array,total))
 
Upvote 0
Solution
If you want it with headers too:

Excel Formula:
=LET(
i,A2:G5,
array,SORT(VSTACK(CHOOSECOLS(i,2,1,3),CHOOSECOLS(i,4,1,5),CHOOSECOLS(i,6,1,7)),1),
scan,SCAN(0,CHOOSECOLS(array,3),LAMBDA(a,b,a+b)),
headers,HSTACK(B1,A1,C1,"TOTAL"),
VSTACK(headers,HSTACK(array,scan)))
 
Upvote 0
Here is an alternative solution using Power Query

Power Query:
let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    #"Unpivoted Other Columns" = Table.UnpivotOtherColumns(Source, {"NAME"}, "Attribute", "Value"),
    #"Added Custom" = Table.AddColumn(#"Unpivoted Other Columns", "Amount", each if Text.StartsWith([Attribute], "AMT") then [Value] else null),
    #"Filled Up" = Table.FillUp(#"Added Custom",{"Amount"}),
    #"Changed Type1" = Table.TransformColumnTypes(#"Filled Up",{{"Amount", Int64.Type}}),
    #"Filtered Rows" = Table.SelectRows(#"Changed Type1", each Text.StartsWith([Attribute], "DATE")),
    #"Removed Columns" = Table.RemoveColumns(#"Filtered Rows",{"Attribute"}),
    #"Changed Type" = Table.TransformColumnTypes(#"Removed Columns",{{"Value", type date}}),
    #"Added Index" = Table.AddIndexColumn(#"Changed Type", "Index", 1, 1, Int64.Type),
    #"Renamed Columns" = Table.RenameColumns(#"Added Index",{{"Value", "Date"}}),
    #"Added Custom1" = Table.AddColumn(#"Renamed Columns", "Custom", each List.Sum(List.FirstN(#"Renamed Columns"[Amount], [Index] ) )), 
    #"Removed Columns1" = Table.RemoveColumns(#"Added Custom1",{"Index"})
in
    #"Removed Columns1"
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,175
Members
453,021
Latest member
Justyna P

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