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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
qaschris
Regular Visitor

Recursive Nested Child List/Record Objects, Add Column Value to Table

Hi, i'm new to Power BI.  I have a development background, but learning M and the intricacies of Power BI has been a challenge.

 

I am working with some data-oriented reports, in this case pulling a JSON payload from a RESTful API, and working with that data.  I am receiving an object which has nested Lists of Record objects, each of which may have more nested Lists of Record objects.

 

The top level object appears as thus:

qaschris_0-1700600806227.png

The property in which I'm interested is 'children'.  I am not interested in the 'links' property.

 

Drilling down, the objects are similar:

qaschris_1-1700600894300.png

Expanded Record:

qaschris_2-1700600926284.png

And further in:

qaschris_3-1700600962182.png

And so on, for an unknown total object depth.

 

I'm trying to figure out how to navigate these structures recursively to make a cohesive but simple list of the 'id' property for every object in the structure.  I've searched extensively and the recursion methods I've found don't match up to the data structures that I'm using here.  The closest I found was Mike Honey's example of recursing tables, but as these aren't table objects to begin with, it doesn't quite fit the bill.  I would appreciate a little guidance from some more seasoned folks on a tidy way of doing this.

 

Thanks in advance for any advice!

1 ACCEPTED SOLUTION
qaschris
Regular Visitor

Alright, so I applied the script that I linked in my last response, and got a completely flattened (if ugly) table that looks like this.

qaschris_0-1701119734578.png

 

Once I had my flattened data, I filtered out the unnecessary columns, only keeping the first Value column and any column with "Name" in it as these are the dynamic columns that describe the data type.  I then unpivoted my columns to achieve the following.

qaschris_1-1701119836615.png

 

I then filtered on the Value.1 column for all values that match only "id" and got my short list of object ids.

View solution in original post

4 REPLIES 4
qaschris
Regular Visitor

Alright, so I applied the script that I linked in my last response, and got a completely flattened (if ugly) table that looks like this.

qaschris_0-1701119734578.png

 

Once I had my flattened data, I filtered out the unnecessary columns, only keeping the first Value column and any column with "Name" in it as these are the dynamic columns that describe the data type.  I then unpivoted my columns to achieve the following.

qaschris_1-1701119836615.png

 

I then filtered on the Value.1 column for all values that match only "id" and got my short list of object ids.

Syndicate_Admin
Administrator
Administrator

 Power Query supports recursive function calls - that would let you explore all the tendrils/ends of your hierarchy tree and collect the IDs from each.

Syndicate_Admin
Administrator
Administrator

JSON is usually giving you ragged hierarchies.  Power Query needs to produce a flat table.  Round hole, meet square peg. Square peg, meet round hole.

 

You will have to make decisions.

 

- what data do you need from the JSON

- what is the flat format that you want to feed to the Power BI part (the data model and UI)

 

There is no universal or simple answer.  You have to make decisions, and they can sometimes be painful, and destroy information along the way.

Thanks for the reply.  In short, all I need is the "id" property from each of the nested objects so I don't care about losing the remainder of the data.  It's finding the way to dynamically and recursively navigate the heirarchies that's giving me trouble.  Since it's the structure of an API call over which I have no control, I'll have to process said structure within Power BI.  I may have found a rather complex script that might do the job but I won't know until I try to implement it within my project. 

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

Find out what's new and trending in the Fabric community.

July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

Top Solution Authors