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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

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
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.