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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Anonymous
Not applicable

Flattening an 'n' level JSON file

Hi,

 

I'm trying to turn an (theoretically) infinitely nested JSON into a table, similar to the below.

 

I'm not sure where to start as the moment PowerQuery reads it as a JSON I'm doomed to recursively navigate through it

 

Tree.png

 

accountprojecttypenamepath_idshared_id
AEC_Control21b37e20-d2...transformationDefault814d8939-6e…814d8939-6e7d-4412-9db5-a2fcc393658af094ff2a-f770-480d-a18c-ede9e14e2b7e
AEC_Control21b37e20-d2...transformation(IfcBuilding)814d8939-6e…46a684ca-879b-4308-a02b-9c7fbeb0f2a000482a85-feed-4f36-a476-3c5b9d666a11
AEC_Control21b37e20-d2...transformationRF - Roof Level814d8939-6e…c8da1f59-3959-4ac2-b702-1ccf86bd2ddc1157c6d9-6c74-4f3a-aa04-b75ea5f2e1a4
AEC_Control21b37e20-d2...transformationBasic Roof -190761:EPDM Membrane on Rigid Insul on Metal Deck:314949814d8939-6e…f9a39fb7-d1dd-48b3-a59d-7440b10b9adabf51f351-8d5a-4ad2-9633-b06a22742e9d
       
1 REPLY 1
mahoneypat
Microsoft Employee
Microsoft Employee

Since you only provided an image and not the json file, I couldn't try this out directly, but you should be able to do the following

 

- in the query editor, connect to the file as text instead of json

- use Text.Select to keep just numbers, letters and ":"

- filter out the rows that aren't your 8 repeating value pairs (account, project, type, etc.)

- split the column at the ":"

- add a column that creates an "index" with repeats of 8 (1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,3,3 ...)

- pivot the data to get your desired result

 

Regards,

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


Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 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.