Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
Anonymous
Not applicable

Expand table with dynamic list

Hi,

 

I have a step where I create a Custom List1 utilizing the equation:

 

=  List.Union(List.Transform(#"Removed Other Columns1"[Data], each Table.ColumnNames(_)))

 

This give me a list of all the column names in all files (50+) with no duplicates. 

 

My next step I want to expand a table utilizing the list in the Custom List1, but I'm not sure how to call the list. This is definitely wrong, but here is what I used:

 

= Table.ExpandTableColumn(#"Removed Other Columns1", "Data", List.Union(#"CustomList1"[List]))

 

Please let me know if there is a solution!

1 ACCEPTED SOLUTION
camargos88
Community Champion
Community Champion

Hi  @Anonymous ,

 

Try this mcode:

 

let
Source = Table.FromRecords({
[Age = 1, Name = "Bob", Phone = "123-4567", Data = Table.FromList({[Age = 10, ID = "10"],[Age = 20, ID = "20"]}, Record.FieldValues,{"Age", "ID"})],
[Age = 2, Name = "Jim", Phone = "987-6543", Data = Table.FromList({[Age = 20, Email = "Bob@gmail.com"],[Age = 30, Email = "Jim@gmail.com"]}, Record.FieldValues,{"Age", "Email"})],
[Age = 3, Name = "Paul", Phone = "543-7890", Data = Table.FromList({[Age = 30, LastName = "Bob"],[Age = 40, LastName = "Jim"]}, Record.FieldValues,{"Age", "LastName"})]
}),
ListColumns = List.Distinct(List.Union(List.Transform(Source[Data], each Table.ColumnNames(_)))),
Expand = Table.ExpandTableColumn(Source, "Data", ListColumns, List.Transform(ListColumns, each _ & ".1"))
in
Expand



Did I answer your question? Mark my post as a solution!

Proud to be a Super User!



View solution in original post

1 REPLY 1
camargos88
Community Champion
Community Champion

Hi  @Anonymous ,

 

Try this mcode:

 

let
Source = Table.FromRecords({
[Age = 1, Name = "Bob", Phone = "123-4567", Data = Table.FromList({[Age = 10, ID = "10"],[Age = 20, ID = "20"]}, Record.FieldValues,{"Age", "ID"})],
[Age = 2, Name = "Jim", Phone = "987-6543", Data = Table.FromList({[Age = 20, Email = "Bob@gmail.com"],[Age = 30, Email = "Jim@gmail.com"]}, Record.FieldValues,{"Age", "Email"})],
[Age = 3, Name = "Paul", Phone = "543-7890", Data = Table.FromList({[Age = 30, LastName = "Bob"],[Age = 40, LastName = "Jim"]}, Record.FieldValues,{"Age", "LastName"})]
}),
ListColumns = List.Distinct(List.Union(List.Transform(Source[Data], each Table.ColumnNames(_)))),
Expand = Table.ExpandTableColumn(Source, "Data", ListColumns, List.Transform(ListColumns, each _ & ".1"))
in
Expand



Did I answer your question? Mark my post as a solution!

Proud to be a Super User!



Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.