cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
john_dawson Frequent Visitor
Frequent Visitor

ExpandRecordColumn versus ExpandListColumn

Problem: when expanding a JSON dataset, programmatically, you can expand a list of Tables using Table.ExpandListColumn, specifying only the column name to be expanded, which is fine. But if you want to expand a list of Records, you seem to have to specify the column names manually. It would be preferable, to have a more generic, less fragile, solution, that would allow you request all columns, without needing to name them, or at least to use a function that could return those column names, before expansion, so to speak. Is this possible?

1 ACCEPTED SOLUTION

Accepted Solutions
Super User
Super User

Re: ExpandRecordColumn versus ExpandListColumn

Hi @john_dawson,

 

you can use this function instead:

 

(Table as table, ColumnName as text) =>
Table.ExpandRecordColumn(Table, ColumnName, Record.FieldNames(Table.Column(Table, ColumnName){0}))

It automatically expands all fields of the records that are found in the first rows record.

 

If the records are different and the names of all records within that column have to be taken into account, you can use this function instead:

 

 

= (Table as table, ColumnName as text) =>
Table.ExpandRecordColumn(Table, ColumnName, Record.FieldNames(Record.Combine(Table.Column(Table, ColumnName))))

might be a bit slower then

If you liked my solution, please give it a thumbs up. An if I did answer your question, please mark my post as a solution. Thanks!

Proud to be a Datanaut!

Imke Feldmann

How to integrate M-code into your solution -- Check out more PBI- learning resources here -- Performance Tipps for M-queries




View solution in original post

3 REPLIES 3
Super User
Super User

Re: ExpandRecordColumn versus ExpandListColumn

Hi @john_dawson,

 

you can use this function instead:

 

(Table as table, ColumnName as text) =>
Table.ExpandRecordColumn(Table, ColumnName, Record.FieldNames(Table.Column(Table, ColumnName){0}))

It automatically expands all fields of the records that are found in the first rows record.

 

If the records are different and the names of all records within that column have to be taken into account, you can use this function instead:

 

 

= (Table as table, ColumnName as text) =>
Table.ExpandRecordColumn(Table, ColumnName, Record.FieldNames(Record.Combine(Table.Column(Table, ColumnName))))

might be a bit slower then

If you liked my solution, please give it a thumbs up. An if I did answer your question, please mark my post as a solution. Thanks!

Proud to be a Datanaut!

Imke Feldmann

How to integrate M-code into your solution -- Check out more PBI- learning resources here -- Performance Tipps for M-queries




View solution in original post

john_dawson Frequent Visitor
Frequent Visitor

Re: ExpandRecordColumn versus ExpandListColumn

Neat! Thanks very much, ImkeF

bradleyg New Member
New Member

Re: ExpandRecordColumn versus ExpandListColumn

Woo-hoo, thank you! The first function worked for me!

Helpful resources

Announcements
New Topics Started Badges Coming

New Topics Started Badges Coming

We're releasing new versions of the badge that everyone's talking about. ;) Check your inbox for notifications.

MBAS 2020

Save the new date (and location)!

Our business applications community is growing—so we needed a different venue, resulting in a new date and location. See you there!

Difinity Conference

Difinity Conference

The largest Power BI, Power Platform, and Data conference in New Zealand

Top Kudoed Authors (Last 30 Days)