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
bboysen
Regular Visitor

JSON Keys Change for each record

Hello,

 

I have a JSON file that I am pulling via API; I am running into an issue when trying to expand the record into individual columns to access the values. Below is a snip of the JSON object.  I am trying to access the start and stop within the time_bucket, but the next JSON key changes each time that value gets updated. Any insight on how to dynamically access the data would be greatly appreciated.

 

"-NNNhF0luJcfv-QqKwux": {
            "sections": {
                "midpoint_section": {
                          "time_bucket": {
                            "-NNgtF6n9q3qeaE_ArL6": {
                                "start"1675790384409,
                                "stop"1675790451218,
                                "uid""CcjuXG7To7XXP0C0R696v7n1zHk2"
                              }
                        }
                    }
        },
 "-NNNhFuUfWs6cL9u3Y_S": {    
            "sections": {
                "midpoint_section": {
                        "time_bucket": {
                            "-NNgtyoJmdB5xbNb92fX": {
                                "start"1675790606877,
                                "stop"1675790642483,
                                "uid""CcjuXG7To7XXP0C0R696v7n1zHk2"
                            }
                        }
                    }
        }
1 ACCEPTED SOLUTION
jbwtp
Memorable Member
Memorable Member

Hi @bboysen,

 

the code which I posted works with a record and I think that you are trying to apply it to a table (according to what I see).

 

try using AddColumn [from the point on your screenshot, i.e. the time_stamp column does exist, but not yet expanded] to add this code:

Record.Field([time_bucket], Record.FieldNames([time_bucket]){0})

This will/should estract the record with start/stop regardless of the actual "tag" of the record.

 

Cheers,

John  

I think 

View solution in original post

4 REPLIES 4
jbwtp
Memorable Member
Memorable Member

Hi @bboysen,

 

This is a generalised approach, let me know if you'll have difficulties adopting it for your scenario:

let
    Source = "{""-NNNhF0luJcfv-QqKwux"": {#(cr)#(lf)            ""sections"": {#(cr)#(lf)                ""midpoint_section"": {#(cr)#(lf)                          ""time_bucket"": {#(cr)#(lf)                            ""-NNgtF6n9q3qeaE_ArL6"": {#(cr)#(lf)                                ""start"": 1675790384409,#(cr)#(lf)                                ""stop"": 1675790451218,#(cr)#(lf)                                ""uid"": ""CcjuXG7To7XXP0C0R696v7n1zHk2""#(cr)#(lf)                              }#(cr)#(lf)                        }#(cr)#(lf)                    }#(cr)#(lf)        }#(cr)#(lf)}#(cr)#(lf)}",
    json = Json.Document(Source),
    record = List.Last(List.Generate(()=>json, each not List.Contains(Record.FieldNames(_), "start"), each Record.Field(_, Record.FieldNames(_){0}))),
    Custom1 = Record.Field(record, Record.FieldNames(record){0})
in
    Custom1

 

Kind regards,

John

John, thank you for the information this works great with the one recorded. When I apply this solution to my main data file it gets the following error message. 

 

bboysen_0-1676498399854.png

 

 

Little more detail and I should have included some of this before. When I click to expand time_bucket I get the following 

bboysen_1-1676498516219.png

When I click to load more, I get about 200 more records within the list. 

 

Each one creates a new column within the table. 

bboysen_2-1676498616763.png

 

I am trying to figure out how to get down to the next record without creating new columns for each of the parent records. 

 

jbwtp
Memorable Member
Memorable Member

Hi @bboysen,

 

the code which I posted works with a record and I think that you are trying to apply it to a table (according to what I see).

 

try using AddColumn [from the point on your screenshot, i.e. the time_stamp column does exist, but not yet expanded] to add this code:

Record.Field([time_bucket], Record.FieldNames([time_bucket]){0})

This will/should estract the record with start/stop regardless of the actual "tag" of the record.

 

Cheers,

John  

I think 

John, this is money. Thank you, sir; the sad part is that I was missing one little item. 

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!

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.