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?

23 hours ago in Power BI by Evanjalin
• 19,330 points
13 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 22 hours ago by anonymous
• 19,330 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
3,926 views
0 votes
1 answer

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

Best practices to guarantee that the defined ...READ MORE

answered Dec 23, 2024 in Power BI by pooja
• 16,840 points
90 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,867 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,130 points
1,525 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,130 points
2,870 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,654 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,801 views
0 votes
1 answer

Why am I getting a 401 Unauthorized error when renaming a Power BI dataflow using the Power BI REST API, and how can I fix it?

A 401 Unauthorized error when renaming a ...READ MORE

answered Feb 27 in Power BI by anonymous
• 19,330 points
121 views
0 votes
1 answer

How can I call an API in Power BI when connected through a VPN?

Challenges When Calling an API via VPN Network ...READ MORE

answered Feb 27 in Power BI by anonymous
• 19,330 points
56 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