How do I extract JSON data from an API and transform it into a structured table in Power Query

0 votes

How do I extract JSON data from an API and transform it into a structured table in Power Query?
I am retrieving JSON data from an API and need to convert it into a structured table format in Power Query. What steps should I follow to correctly parse, expand, and transform the nested JSON data while handling dynamic schema variations?

Mar 13 in Power BI by Evanjalin
• 25,690 points
62 views

1 answer to this question.

0 votes

To extract and transform JSON data from an API in Power Query:

 Connect to API & Load JSON

Source = Json.Document(Web.Contents("https://api.example.com/data"))

Expand & Structure Data

  • If the root is a list, use Table.FromList(Source).
  • If it's a record, use Table.FromRecords({Source}).
  • Expand nested records/lists using Table.ExpandRecordColumn().

 Handle Dynamic Schema

  • Use Record.ToTable() for varying fields:
Table.FromRecords(List.Transform(Source, each Record.ToTable(_)))

 Convert & Clean Data

  • Use Table.TransformColumnTypes() to assign correct types.
  • Remove unwanted columns with Table.RemoveColumns().

answered Mar 13 by anonymous
• 25,690 points

Related Questions In Power BI

0 votes
1 answer

I have a web API with basic authorisation and username and password. How do i connect to it in Power BI?

Hey, @There, I found your query is quite ...READ MORE

answered Oct 29, 2020 in Power BI by Gitika
• 65,770 points
4,017 views
0 votes
2 answers

How can I preserve table data type columns from Power Query in the Power BI Data Model?

Ensure data types are correctly set in ...READ MORE

answered Apr 3 in Power BI by anonymous
• 22,890 points
125 views
0 votes
1 answer

How do you add a slicer from different table in Power BI?

Firstly select the table that u want ...READ MORE

answered Oct 10, 2023 in Power BI by Monika kale

edited Mar 5 1,932 views
0 votes
1 answer

Displaying Table Schema using Power BI with Azure IoT Hub

Answering your first question, Event Hubs are ...READ MORE

answered Aug 1, 2018 in IoT (Internet of Things) by nirvana
• 3,090 points
1,599 views
+1 vote
1 answer

Unable to install connector for Power Bi and PostgreSQL

I think the problem is not at ...READ MORE

answered Aug 22, 2018 in Power BI by nirvana
• 3,090 points
2,938 views
+2 votes
2 answers

Migrate power bi collection to power bi embedded

I agree with Kalgi, this method is ...READ MORE

answered Oct 11, 2018 in Power BI by Hannah
• 18,520 points
1,722 views
+1 vote
1 answer

Connect power bi desktop to dataset and create custom reports

Open power bi report nd sign in ...READ MORE

answered Oct 10, 2023 in Power BI by Monika kale

edited Mar 5 1,886 views
0 votes
1 answer

How can I transform nested JSON data into a structured table format?

Use Power BI Power Query transformation to ...READ MORE

answered 5 days ago in Power BI by anonymous
• 25,690 points
31 views
0 votes
1 answer

How do I dynamically rename multiple columns in Power Query based on a mapping table?

To dynamically rename multiple columns in Power ...READ MORE

answered Apr 1 in Power BI by anonymous
• 25,690 points
100 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP