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

Dynamic table headers from API

Hi all,

 

I need help dynamically pulling headers when importing data via API in PowerQuery. I'm currently entering headers manually, which is terribly inefficient and requires manual updates whenever new fields are added to the API.

 

Here's what I have:

let

    endpoint = "(REST API endpoint URL)",
    directive= "A",
    cache    = "false",
    command  = Record.FromList({keys})  ,
    headers  = Record.FromList({command},{"Headers"}),
    payload  = Json.Document(Web.Contents(endpoint, headers)),
    value = payload[value],
    #"Converted to Table" = Table.FromList(value, Splitter.SplitByNothing(), null, null, ExtraValues.Error),
    #"Expanded Column1" = Table.ExpandRecordColumn(#"Converted to Table", "Column1", {
"Header 1",
"Header 2",
"Header 3"        
})
 
in

    #"Expanded Column1"

In this query's current state, only the identified headers ("Header 1", "Header 2", "Header 3") are pulled into the table.

 

What I'd rather say is, "Give me every column from all headers available." That way, when I refresh the dataset, any new columns will be pulled dynamically.

 

Any help would be appreciated. Thanks!

1 ACCEPTED SOLUTION
lbendlin
Super User
Super User

#"Expanded Column1" = Table.ExpandRecordColumn(#"Converted to Table", "Column1", Headers)

View solution in original post

3 REPLIES 3
lbendlin
Super User
Super User

#"Expanded Column1" = Table.ExpandRecordColumn(#"Converted to Table", "Column1", Headers)
Anonymous
Not applicable

It worked. Thanks so much!

Anonymous
Not applicable

I have a question. How did you define key?

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.

Top Solution Authors