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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
seanwu
Regular Visitor

Insert a column into a nested table with values from the nesting table using Table.TransformColumns

Hi,

I have a two-column table (Source): column A (ColA) and Column B (ColB).

1. ColA has a different value in each row (row 1 value is "A", row 2 value is "B" etc.).

2. ColB has a different nested table (NestedTbl) in each row.

 

I want to do a column transformation on each of the NestedTbl in ColB. The column transformation is to insert an additional column into each of the NestedTbl so that the inserted column (let's called it "InsertCol") has a value in the same row of ColA (The InsertCol in NestedTbl in row 1 would be all "A", The InsertCol in NestedTbl in row 2 would be all "B", etc.). Here is my code:

 

=Table.TransformColumns(Source,

{

"ColB", each Table.AddColumn(_, "InsertCol", each Source[ColA]

}

)

The "InsertCol" is indeed inserted into the NestedTbl, however, the values in the InsertCol is a List of ColA. I understand why this happens (it is because of the Italilized section of the above code, which returns a List), But I don't know how to solve this. Can someone shed some light on this? Essentially it seems to me this asks for a solution to reference from a nested table (NestedTbl) to the nesting (Source) table.

 

Thanks, 

 

Sean

1 REPLY 1
wdx223_Daniel
Super User
Super User

=Table.ReplaceValue(Source,

each [ColA],

"", (x,y,z)=> Table.AddColumn(x, "InsertCol",each y),

{"ColB"}

)

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.