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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

Dynamically expanding all the columns containing lists/records received in a JSON response from APIs

I am new to Power Query and working on Power BI.

 

There are multiple Web APIs that return a nested JSON response having multiple lists and records.

 

I need to write a single generic code to dynamically expand all the lists and records in any JSON response using Power Query, without knowing the names/number of the key-value pairs in it.

 

Also, the datatypes of the columns should be set automatically using the same code.

 

Any help is greatly appreciated.

 

Thanks in advance.

 

4 REPLIES 4
ImkeF
Super User
Super User

Hi @Arif1033 ,
instead of null you need to pass in the (reference to the) JSON that you want to analyze/expand.

 

Imke Feldmann (The BIccountant)

If you liked my solution, please give it a thumbs up. And if I did answer your question, please mark this post as a solution. Thanks!

How to integrate M-code into your solution -- How to get your questions answered quickly -- How to provide sample data -- Check out more PBI- learning resources here -- Performance Tipps for M-queries

I apologise i did not quite get it - am new to power query and API's - am using the below rest API - can you give me some examples of what refrence i should be using it

 

https://XXXX.com/jira/rest/api/2/search?jql=project in (xxx,xxx) AND created >= startOfYear()&maxRes... 

Arif1033
Regular Visitor

Hi, I used the M-code in the below link - 

https://www.thebiccountant.com/2018/06/17/automatically-expand-all-fields-from-a-json-document-in-po...

 

bu now i see an i option like below (Image included) - Please let me know what should be the next steps here

after i click on Invoice i get an error (Image included)

PQ.JPG PQ-2.JPG

ImkeF
Super User
Super User

I wrote a function for that some time ago:

https://www.thebiccountant.com/2018/06/17/automatically-expand-all-fields-from-a-json-document-in-po...

Imke Feldmann (The BIccountant)

If you liked my solution, please give it a thumbs up. And if I did answer your question, please mark this post as a solution. Thanks!

How to integrate M-code into your solution -- How to get your questions answered quickly -- How to provide sample data -- Check out more PBI- learning resources here -- Performance Tipps for M-queries

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.