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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
vbharakhada
Frequent Visitor

How to expand multiple record columns dynamically

I have multiple columns which contains Record and inside record , I need only 'value'.

I need to ExpandRecordColumn for multiple columns in a single step.

I need to expand the yellow highlighted columns dynamically.

vbharakhada_0-1712059045070.png

 

2 ACCEPTED SOLUTIONS
dufoq3
Super User
Super User

Hi @vbharakhada, add this as new step (not custom column, but new step)

Replace

  1. {"Column1", "Column4, "Column5"} with your columns with records you want to expand
  2. Source with your previous_step reference

 

= List.Accumulate(
    {"Column1", "Column4", "Column5"},
    Source,
    (s,c)=> Table.ExpandRecordColumn(s, c, List.Combine(List.Transform(Table.Column(s, c), Record.FieldNames))))

 

 

Whole code with sample data:

 

let
    Source = #table(null, {{[a=1], 12345, "abc", [b=2], [c=3]}, {[d=1], 23456, "bcd", [e=2], [f=3]}}),
    ExpandedColumnsDynamic = List.Accumulate(
    {"Column1", "Column4", "Column5"},
    Source,
    (s,c)=> Table.ExpandRecordColumn(s, c, List.Combine(List.Transform(Table.Column(s, c), Record.FieldNames))))
in
    ExpandedColumnsDynamic

 


Note: Check this link to learn how to use my query.
Check this link if you don't know how to provide sample data.

View solution in original post

Try this:

 

Result:

dufoq3_0-1712065935082.png

 

let
    Source = #table(null, {
{"key-1", "summary1",[self="customFieldOption/10838",value="Regression",id=783], [self="celdOptio838",value="sion",id=1273], [self="custom",value="UAT1",id=2742]}, 
{"key-2", "summary2",null,  [self="egrth/jyt",value="UAT",id=3875], [self="testing",value="Testing Case",id=53]},
{"key-3", "summary3",[self="clhchdwj",value="definite",id=754642],  [self="rtjyf/rhtj",value="UAT",id=3875], null}}),
    ExpandColumnsDynamic = List.Accumulate(
    {"Column3", "Column4", "Column5"},
    Source,
    (s,c)=> [ a = List.Distinct(List.Combine(List.Select(List.Transform(Table.Column(Source, c), each try Record.FieldNames(_) otherwise null), (x)=> x <> null))),
              b = Table.ExpandRecordColumn(s, c, a, List.Transform(a, (x)=> c & "_" & x ))
            ][b] )
in
    ExpandColumnsDynamic

 


Note: Check this link to learn how to use my query.
Check this link if you don't know how to provide sample data.

View solution in original post

6 REPLIES 6
dufoq3
Super User
Super User

Hi @vbharakhada, add this as new step (not custom column, but new step)

Replace

  1. {"Column1", "Column4, "Column5"} with your columns with records you want to expand
  2. Source with your previous_step reference

 

= List.Accumulate(
    {"Column1", "Column4", "Column5"},
    Source,
    (s,c)=> Table.ExpandRecordColumn(s, c, List.Combine(List.Transform(Table.Column(s, c), Record.FieldNames))))

 

 

Whole code with sample data:

 

let
    Source = #table(null, {{[a=1], 12345, "abc", [b=2], [c=3]}, {[d=1], 23456, "bcd", [e=2], [f=3]}}),
    ExpandedColumnsDynamic = List.Accumulate(
    {"Column1", "Column4", "Column5"},
    Source,
    (s,c)=> Table.ExpandRecordColumn(s, c, List.Combine(List.Transform(Table.Column(s, c), Record.FieldNames))))
in
    ExpandedColumnsDynamic

 


Note: Check this link to learn how to use my query.
Check this link if you don't know how to provide sample data.

Hi @dufoq3 , 
thank you so much, It's working for some scenario but unable work on the below scenario.

I have attached sample table that needs to be expanded.

 

let
    Source = #table(null, {
{"key-1", "summary1",[self="customFieldOption/10838",value="Regression",id=783], [self="celdOptio838",value="sion",id=1273], [self="custom",value="UAT1",id=2742]}, 
{"key-2", "summary2",null,  [self="egrth/jyt",value="UAT",id=3875], [self="testing",value="Testing Case",id=53]},
{"key-3", "summary3",[self="clhchdwj",value="definite",id=754642],  [self="rtjyf/rhtj",value="UAT",id=3875], null}})
in
    Source

 


Regards

Try this:

 

Result:

dufoq3_0-1712065935082.png

 

let
    Source = #table(null, {
{"key-1", "summary1",[self="customFieldOption/10838",value="Regression",id=783], [self="celdOptio838",value="sion",id=1273], [self="custom",value="UAT1",id=2742]}, 
{"key-2", "summary2",null,  [self="egrth/jyt",value="UAT",id=3875], [self="testing",value="Testing Case",id=53]},
{"key-3", "summary3",[self="clhchdwj",value="definite",id=754642],  [self="rtjyf/rhtj",value="UAT",id=3875], null}}),
    ExpandColumnsDynamic = List.Accumulate(
    {"Column3", "Column4", "Column5"},
    Source,
    (s,c)=> [ a = List.Distinct(List.Combine(List.Select(List.Transform(Table.Column(Source, c), each try Record.FieldNames(_) otherwise null), (x)=> x <> null))),
              b = Table.ExpandRecordColumn(s, c, a, List.Transform(a, (x)=> c & "_" & x ))
            ][b] )
in
    ExpandColumnsDynamic

 


Note: Check this link to learn how to use my query.
Check this link if you don't know how to provide sample data.

Thank you so much for the help, Even ChatGPT was not able to help me. Thanks a lot.🤟🤟

If you don't want to select columns with records manualy, you can use this as 1st argument for List.Accumulate instead of hardcoded {"Column1", "Column2", "Column3"}

List.Transform(List.PositionOf(List.Transform(Table.ToColumns(Source), (x)=> List.AnyTrue(List.Transform(x, (y)=> y is record))), true, Occurrence.All), each Table.ColumnNames(Source){_})

 

Whole code:

let
    Source = #table(null, {
{"key-1", "summary1",[self="customFieldOption/10838",value="Regression",id=783], [self="celdOptio838",value="sion",id=1273], [self="custom",value="UAT1",id=2742]}, 
{"key-2", "summary2",null,  [self="egrth/jyt",value="UAT",id=3875], [self="testing",value="Testing Case",id=53]},
{"key-3", "summary3",[self="clhchdwj",value="definite",id=754642],  [self="rtjyf/rhtj",value="UAT",id=3875], null}}),
    ExpandColumnsDynamic = List.Accumulate(
    List.Transform(List.PositionOf(List.Transform(Table.ToColumns(Source), (x)=> List.AnyTrue(List.Transform(x, (y)=> y is record))), true, Occurrence.All), each Table.ColumnNames(Source){_}), //Columns containing record
    Source,
    (s,c)=> [ a = List.Distinct(List.Combine(List.Select(List.Transform(Table.Column(Source, c), each try Record.FieldNames(_) otherwise null), (x)=> x <> null))),
              b = Table.ExpandRecordColumn(s, c, a, List.Transform(a, (x)=> c & "_" & x ))
            ][b] )
in
    ExpandColumnsDynamic

 


Note: Check this link to learn how to use my query.
Check this link if you don't know how to provide sample data.

You're welcome.


Note: Check this link to learn how to use my query.
Check this link if you don't know how to provide sample data.

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!

September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 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