Forum Discussion
JamesMcEwan
4 years agoHelper I
Expanding ListColumns within Nested Tables
Hi all, I am looking to expand a ListColumn within a nested table, however I would like to so this without adding a new column. Is there a way to expand the list without adding a new column to the ...
- 4 years ago
Hi,
So you probably want something like this:
let Source = Table.FromRecords( { [Name = "Bob", Color = "Blue"], [Name = "Jim", Color = "Yellow"], [Name = "Paul", Color = "Green"] } ), #"AddTab;e"= Table.AddColumn (Source, "TypeID", each Table.FromRecords( { [Type= "Small", ID = {1,2,3}], [Type = "Medium", ID = {2,4,6}], [Type = "Large", ID = {1,3,6}] } ) ), TransformColumn = Table.TransformColumns(#"AddTab;e",{"TypeID", each Table.ExpandListColumn(_, "ID")}) in TransformColumnHope it helps,
Artur
artpil
4 years agoResolver II
Hi,
So you probably want something like this:
let
Source =
Table.FromRecords(
{
[Name = "Bob", Color = "Blue"],
[Name = "Jim", Color = "Yellow"],
[Name = "Paul", Color = "Green"]
}
),
#"AddTab;e"=
Table.AddColumn (Source, "TypeID", each
Table.FromRecords(
{
[Type= "Small", ID = {1,2,3}],
[Type = "Medium", ID = {2,4,6}],
[Type = "Large", ID = {1,3,6}]
}
)
),
TransformColumn = Table.TransformColumns(#"AddTab;e",{"TypeID", each Table.ExpandListColumn(_, "ID")})
in
TransformColumn
Hope it helps,
Artur
- JamesMcEwan4 years agoHelper I
Hi artpil,
This is great and worked a treat. I also had just figured out my own solution - so will copy below, in case there is a use case for either.
Thanks!
let Source = Table.FromRecords( { [Name = "Bob", Color = "Blue"], [Name = "Jim", Color = "Yellow"], [Name = "Paul", Color = "Green"] } ) in Table.AddColumn (Source, "TypeID", each let _usertable = Table.FromRecords( { [Type= "Small", ID = {1,2,3}], [Type = "Medium", ID = {2,4,6}], [Type = "Large", ID = {1,3,6}] } ) in Table.ExpandListColumn( _usertable,"ID" ) )