cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
John_Martel
New Member

Generic way to expand all columns in Power Query from the import of a nested JSON format

Hello,

 

I often deal with complex nested JSON files that consist of array of records of array of records etc... What I would like to do is to be import the JSON file in an "all-expanded mode" where are all the columns of lists and records are expanded . Right now i have to repeatdly click on the "double arrow" on the header of every expandable column to split a column of lists or a column of records until there are no more expandable columns . Given that the JSON files have deep nesting manually clicking to expand columns is not practical, moreoever since the JSON files have varying formats, i cannot create a function from the steps recorded when expanding column after column. Is there a general way to expand all columns in a table?

1 ACCEPTED SOLUTION
edhans
Super User
Super User

I don't think so. When you expand, it changes the shape of the table, and expanding in different orders or ways will change the outcome. Expanding a nested list to rows will impact how a subsequent list expansion will happen, so even if someone were to write function that would loop through all lists and tables and expand, they best they could do is expand them in a specific order (first to last) in a specific way, (to rows, to columns if availalble), all of which can change the results.



Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

DAX is for Analysis. Power Query is for Data Modeling


Proud to be a Super User!

MCSA: BI Reporting

View solution in original post

2 REPLIES 2
edhans
Super User
Super User

I don't think so. When you expand, it changes the shape of the table, and expanding in different orders or ways will change the outcome. Expanding a nested list to rows will impact how a subsequent list expansion will happen, so even if someone were to write function that would loop through all lists and tables and expand, they best they could do is expand them in a specific order (first to last) in a specific way, (to rows, to columns if availalble), all of which can change the results.



Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

DAX is for Analysis. Power Query is for Data Modeling


Proud to be a Super User!

MCSA: BI Reporting

View solution in original post

Thanks for your answer. It makes sense. In my case, I dont really care about the order of the columns. So my best bet is to write a function.

Helpful resources

Announcements
Power BI October Update 2021.jpg

Power BI Release

Click here to read more about the October 2021 Release!

Microsoft Ignite 768x460.png

Find your focus

Explore the latest tools,training sessions,technical expertise, networking and more.

Power BI Womens Summit 2021 768 x460.jpg

Interviews, learning sessions, allies, and more!

#PowerBIWomenSummit

Teds Dev Camp Oct. 2021 768x460.jpg

Power BI Dev Camp - October 28th, 2021

Mark your calendars and join us for our next Power BI Dev Camp!

Top Solution Authors
Top Kudoed Authors