How to create nested Table appended from row valus / column data

Radoslaw Poprawski

Active Member
Joined
Jun 19, 2021
Messages
398
Office Version
  1. 365
Platform
  1. Windows
Hello.
I need to add a new column which would contain a nested Table in which:
Column1 contains: Reporting from as 1st row and Reporting to as second row
Column2 contains Amount from as 1st row and Amount to as 2nd row,
1652369876080.png

Here is the link to the file.
 

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.
If I'm understanding your requirements correctly, is this what you need:

Power Query:
let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Reporting code", type text}, {"Reporting from", type text}, {"Amount", Int64.Type}, {"Reporting to", type text}}),
    #"Added Custom" = Table.AddColumn(#"Changed Type", "Custom", each [Amount]*-1),
    #"Added Custom1" = Table.AddColumn(#"Added Custom", "Custom1", each Table.FromColumns({#"Added Custom"[Reporting from] & #"Added Custom"[Reporting to],#"Added Custom"[Amount] & #"Added Custom"[Custom]},{"Reporting","Amount"})),
    #"Renamed Columns" = Table.RenameColumns(#"Added Custom1",{{"Amount", "Amount from"}, {"Custom", "Amiunt to"}})
in
    #"Renamed Columns"
 
Upvote 0
Hi,
Thank you.
thats one solution to my problem.
But I was thinking something more of Row related. meaing that created Table in row number 1 contains only data from row row 1 split into 2 rows in nested table.
 
Upvote 0
Ah ok, how about this:
Power Query:
let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Reporting code", type text}, {"Reporting from", type text}, {"Amount", Int64.Type}, {"Reporting to", type text}}),
    #"Added Custom" = Table.AddColumn(#"Changed Type", "Custom", each [Amount]*-1),
    #"Added Custom1" = Table.AddColumn(#"Added Custom", "Custom1", each Table.FromColumns({{Record.Field(_,"Reporting from"), Record.Field(_,"Reporting to")},{Record.Field(_,"Amount"), Record.Field(_,"Custom")}},{"Reporting","Amount"})),
    #"Renamed Columns" = Table.RenameColumns(#"Added Custom1",{{"Amount", "Amount from"}, {"Custom", "Amount to"}})
in
    #"Renamed Columns"
 
Upvote 0
Looks like I made the nested table more complicated than I needed to, here's an update:

Power Query:
let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Reporting code", type text}, {"Reporting from", type text}, {"Amount", Int64.Type}, {"Reporting to", type text}}),
    #"Renamed Columns" = Table.RenameColumns(#"Changed Type",{{"Amount", "Amount from"}}),
    #"Added Custom" = Table.AddColumn(#"Renamed Columns", "Amount to", each [Amount from]*-1),
    #"Added Custom1" = Table.AddColumn(#"Added Custom", "Custom", each Table.FromColumns({{[Reporting from], [Reporting to]},{[Amount from], [Amount to]}},{"Reporting","Amount"}))
in
    #"Added Custom1"
 
Upvote 0
Solution
Thats it!
Thank you.
I know now where I did mistake with Table.FromColumns
it was square brackets. i used {{}}{{}} like this

Thank you.
 
Upvote 0

Forum statistics

Threads
1,223,667
Messages
6,173,678
Members
452,527
Latest member
ineedexcelhelptoday

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