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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

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
Employee
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
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel

Power BI Monthly Update - May 2024

Check out the May 2024 Power BI update to learn about new features.

LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

Top Solution Authors
Top Kudoed Authors