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

The Power BI Data Visualization World Championships is back! It's time to submit your entry. Live now!

Reply
Anonymous
Not applicable

Automatically expand record columns ?

I am getting a JSON response from a web source that I convert into a table and then execute Table.ExpandRecordColumn.

example:

        "metaData": {
            "A""1",
            "B""2",
            "C": "3",
            .
            .

        },

I have found issues with this approach.

1. I sometimes miss some Columns in the expansion because the Table contains 10K rows and the metaData key has 15-20 subkeys (I depicted only "A", "B", "C" above). I end up checking the JSON response and finding the missing subkeys and changing the ExpandRecordColumn for the missing sub-key.

2. A separate team is modifying the metaData object and dynamically adding and removing subkeys in the meData object. I want to be able to get the subkecys without changing ExpandRecordColumn every time.

 

Any suggestions to the above issues would help.

1 ACCEPTED SOLUTION
mahoneypat
Microsoft Employee
Microsoft Employee

Depending on if you have a Table or a Record in your JSON response, you can use the Table.ColumnNames or Record.FieldNames functions to dynamically return the Column/Field names as a List you can then use in your Table.ExpandColumns functions (to replace the List of hardcoded names).

 

Pat

 





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


View solution in original post

3 REPLIES 3
mahoneypat
Microsoft Employee
Microsoft Employee

Depending on if you have a Table or a Record in your JSON response, you can use the Table.ColumnNames or Record.FieldNames functions to dynamically return the Column/Field names as a List you can then use in your Table.ExpandColumns functions (to replace the List of hardcoded names).

 

Pat

 





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


Anonymous
Not applicable

I figured out that the following code works

Table.ExpandRecordColumn(
#"Table From Previous Step",
"metaData",
//Return Field Names
Record.FieldNames(
//Combine the records
Record.Combine(
//Select items in list which are not null, and return a list
List.Select(
//Get a list for the metaData column
Table.Column(
#"Table From Previous Step", "metaData"
),
(x) => x <> null
)
)
)
),

, and performance seems to be OK 

Anonymous
Not applicable

Couple of questions:

1. Do you have sample M code ?

2. Will this degrade power query performance (assume 30K rows and 20 fields for each metaData record)?

Helpful resources

Announcements
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.

Top Solution Authors