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

Join the FabCon + SQLCon recap series. Up next: Power BI, Real-Time Intelligence, IQ and AI, and Data Factory take center stage. All sessions are available on-demand after the live show. Register now

Reply
Anonymous
Not applicable

Format Web Service Data into a Table

I am having issues needed to make a table of 3 columns from a REST API response using Power Query M language.

Below is my code ( at the end of which my table 'newTable' still remains empty.

 

let
    Source = Json.Document(Web.Contents("https://admcorpdev.service-now.com/api/now/stats/incident?sysparm_query=active%3Dtrue%5EpriorityIN1%2C2&sysparm_count=true&sysparm_group_by=caller_id.location.u_region%2Cpriority")),
    result = Table.FromRecords(Source[result]),
    newTable = #table(
        {
            "Priority",  
            "Region",
            "Count"   
        },
        {}
    ),
    TableSource = Table.Buffer(result),
    data = List.Generate( 
        () => [x=0],
        each [x]<= Table.RowCount(result),
        each [ 
            //Generate a new Table and append fields into it
            newTable = Table.InsertRows(newTable,1,{[Priority = "2", Region ="NA",Count = "56"]}),
            x=[x]+1] 
    )
in
    newTable

 

So i have mixed bag of List and record in my data coming in which i want to load in one table with 3 fields.

 

 Capture.JPG

 

 

2 REPLIES 2
v-frfei-msft
Community Support
Community Support

Hi @Anonymous ,

 

Try the updated code as below.

 

let
    Source = Json.Document(Web.Contents("https://admcorpdev.service-now.com/api/now/stats/incident?sysparm_query=active%3Dtrue%5EpriorityIN1%2C2&sysparm_count=true&sysparm_group_by=caller_id.location.u_region%2Cpriority")),
    result = Table.FromRecords(Source[result]),
    newTable = #table(
        {
            "Priority",  
            "Region",
            "Count"   
        },
        {}
    ),
    TableSource = Table.Buffer(result),
    data = List.Generate( 
        () => [x=0],
        each [x]<= Table.RowCount(result),
        each [ 
            //Generate a new Table and append fields into it
            newTable = Table.InsertRows(newTable,1,{[Priority = "2", Region ="NA",Count = "56"]}),
            x=[x]+1] 
    )
in
    TableSource

Regards,

Frank

Community Support Team _ Frank
If this post helps, then please consider Accept it as the solution to help the others find it more quickly.

Hi @Anonymous ,

 

Does that make sense? If so, kindly mark my answer as the solution to close the case please. Thanks in advance.

 

Community Support Team _ Frank
If this post helps, then please consider Accept it as the solution to help the others find it more quickly.

Helpful resources

Announcements
April Power BI Update Carousel

Power BI Monthly Update - April 2026

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

New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

FabCon and SQLCon Highlights Carousel

FabCon & SQLCon Highlights

Experience the highlights from FabCon & SQLCon, available live and on-demand starting April 14th.