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

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

Reply
John255
New Member

Adding Column from another query with value type per row

Hi

 

I have these two querys resulting in these tables

 

TableA

ID

Name

1

john

2dave
3jane
4steve

 

TableB

IDValueNameValue
1age20
1gendermale
1marriedyes
2age22
2gendermale
2marriedno
3age30
3genderfemale
3marriedyes
4age33
4gendermale
4marriedno


I want to add some of the ValueName values from TableB as columns in TableA to get this

 

ID

Name

agegender
1

john

20male
2dave22male
3jane30female
4steve33male

 

I'm still very much on the learning curve here and any help will be very much appriciated.

 

Thank you

 

 

 

1 ACCEPTED SOLUTION
m_dekorte
Super User
Super User

Hi @John255,

 

You can use the Merge Query option on the Ribbon, setting the ID as key to both tables, this will return a table. When we transform that table into a record, we can expand a selection of its fields to new columns.

 

To illustrate

let
    Source = Table.NestedJoin(TableA, {"ID"}, TableB, {"ID"}, "TableB", JoinKind.LeftOuter),
    ReplaceValue = Table.TransformColumns( Source, {{ "TableB", each Record.FromList( _[Value], _[ValueName] ) }} ),
    ExpandRecordFields = Table.ExpandRecordColumn(ReplaceValue, "TableB", {"age", "gender"}, {"age", "gender"})
in
    ExpandRecordFields

 

with this result.

m_dekorte_0-1686345684379.png

 

Ps. If this helps you solve your query, please mark it as solution. Thanks!

View solution in original post

2 REPLIES 2
John255
New Member

Hi @m_dekorte 

Yes, thank you does what I need 🙂

 

m_dekorte
Super User
Super User

Hi @John255,

 

You can use the Merge Query option on the Ribbon, setting the ID as key to both tables, this will return a table. When we transform that table into a record, we can expand a selection of its fields to new columns.

 

To illustrate

let
    Source = Table.NestedJoin(TableA, {"ID"}, TableB, {"ID"}, "TableB", JoinKind.LeftOuter),
    ReplaceValue = Table.TransformColumns( Source, {{ "TableB", each Record.FromList( _[Value], _[ValueName] ) }} ),
    ExpandRecordFields = Table.ExpandRecordColumn(ReplaceValue, "TableB", {"age", "gender"}, {"age", "gender"})
in
    ExpandRecordFields

 

with this result.

m_dekorte_0-1686345684379.png

 

Ps. If this helps you solve your query, please mark it as solution. Thanks!

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

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.

Top Kudoed Authors