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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
KrisCart
New Member

JSON headers at top of file not with data

Hi, I am new to bringing data in via api. I have a json report file brought into power query via api. After clearing out the rows that are just titles etc I am left with this:

KrisCart_0-1694101479914.png

 My issue is the headers are one list and the data is a seperate one. Other files I have used have had the headers repeat in the data but this one does not. I want to get to a flat table but I can't work out how to seperate the headers and data. 

 

When I click the two arrows I get to this stage:

KrisCart_1-1694101652709.png

This has the headers at the top and the rows still as a list below. 

 

Can anyone offer a solution please? 

 

1 ACCEPTED SOLUTION

 

 

let
  Source = Json.Document(File.Contents("C:\Users\xxx\Downloads\response.txt")),
  #"Converted to Table" = Table.FromList(
    Source[rows],
    Splitter.SplitByNothing(),
    null,
    null,
    ExtraValues.Error
  ),
  #"Extracted Values" = Table.TransformColumns(
    #"Converted to Table",
    {"Column1", each Text.Combine(List.Transform(_, Text.From), "|"), type text}
  ),
  #"Split Column by Delimiter" = Table.SplitColumn(
    #"Extracted Values",
    "Column1",
    Splitter.SplitTextByDelimiter("|", QuoteStyle.Csv),
    Source[columnNames]
  )
in
  #"Split Column by Delimiter"

 

 

View solution in original post

4 REPLIES 4
KrisCart
New Member

Hi lbendlin,

 

Thanks for the pointers. File attached, Sample JSON 

 

I have stripped it down to 2 records for ease and have changed any business data. 

 

If you could point me towards any suitable function that would be great. It seems such a simple thing that I know I am missing something. 

 

Thanks

 

 

let
  Source = Json.Document(File.Contents("C:\Users\xxx\Downloads\response.txt")),
  #"Converted to Table" = Table.FromList(
    Source[rows],
    Splitter.SplitByNothing(),
    null,
    null,
    ExtraValues.Error
  ),
  #"Extracted Values" = Table.TransformColumns(
    #"Converted to Table",
    {"Column1", each Text.Combine(List.Transform(_, Text.From), "|"), type text}
  ),
  #"Split Column by Delimiter" = Table.SplitColumn(
    #"Extracted Values",
    "Column1",
    Splitter.SplitTextByDelimiter("|", QuoteStyle.Csv),
    Source[columnNames]
  )
in
  #"Split Column by Delimiter"

 

 

Thanks, the original source was an api but I addressed that by swapping the code line with the filename for the four lines of the api call.

 

It all seems to be working now - thank you very much. 

 

lbendlin
Super User
Super User

There are Power Query functions for that.  Please provide sample data (with sensitive information removed) that covers your issue or question completely, in a usable format (not as a screenshot). Leave out anything not related to the issue.
https://community.fabric.microsoft.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-...

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

Top Kudoed Authors