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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
Anonymous
Not applicable

Looping through API result table only calls function once

I might be missing the answer to this on the forums somewhere, but if someone could give me a point in the right direction I'd appreciate it. All the calls seem to work, except the "each" is supponsed to go through all of the ids in the table and call the API, adding the returned data to one large table. Ideas?

 

 

 

let
    modelParts = List.Transform(StratusModels[id], each getStratusModelPartsforModelPaged(_)),
    modelParts1 = modelParts{0},
    tempTable1 = Table.RemoveColumns(modelParts1,{"points"}),
    tempTable2= Table.ExpandRecordColumn(tempTable1, "propertiesGtp", {"Name", "Code", "Number", "Description", "Size", "Source", "Material", "MaterialGauge", "MaterialThickness", "RequestQuantity", "Length", "Spool", "Section", "Service", "ServiceType", "ServiceAbbreviation", "Drawing", "Phase", "Status", "Area", "Weight", "Manufacturer", "Zone", "Alternate", "Pallet", "EquipmentTag", "Order", "BoughtOut", "CutType", "Material Costs", "Fabrication Cost", "Installation Cost", "Fabrication Hours", "Installation Hours", "Total Cost", "SupplierCode:UPC Code", "SupplierCode:Manufacturer Code", "SupplierCode:OEM Code", "SupplierCode:Harrison", "Product Description", "Product Discount", "Product Finish", "Product Group", "Product Install Type", "Product Material", "Product Name", "Product Range", "Product Size", "Product Source Description", "Product Specification", "Product Status", "Product Supplier", "PipeID", "PipeOD", "C2EndType", "C3EndType", "Fabrication CL Length", "Fabrication Area", "Fabrication Body Area", "Fabrication Skin Area", "Fabrication Insulation Area", "Fabrication Insulation Material Gauge", "Fabrication UniqueId", "C1EndType"}, {"Name", "Code", "Number", "Description.1", "Size", "Source", "Material", "MaterialGauge", "MaterialThickness", "RequestQuantity", "Length", "Spool", "Section", "Service", "ServiceType", "ServiceAbbreviation", "Drawing", "Phase", "Status", "Area", "Weight", "Manufacturer", "Zone", "Alternate", "Pallet", "EquipmentTag", "Order", "BoughtOut", "CutType", "Material Costs", "Fabrication Cost", "Installation Cost", "Fabrication Hours", "Installation Hours", "Total Cost", "SupplierCode:UPC Code", "SupplierCode:Manufacturer Code", "SupplierCode:OEM Code", "SupplierCode:Harrison", "Product Description", "Product Discount", "Product Finish", "Product Group", "Product Install Type", "Product Material", "Product Name", "Product Range", "Product Size", "Product Source Description", "Product Specification", "Product Status", "Product Supplier", "PipeID", "PipeOD", "C2EndType", "C3EndType", "Fabrication CL Length", "Fabrication Area", "Fabrication Body Area", "Fabrication Skin Area", "Fabrication Insulation Area", "Fabrication Insulation Material Gauge", "Fabrication UniqueId", "C1EndType"}),
    tempTable3 = Table.ExpandRecordColumn(tempTable2, "properties", {"CID", "PatternNumber", "Number Of Segments", "Diameter Type", "Angle Tolerance", "Mark Sides", "Leg Lengths", "Fixing Holes On Extension", "Square Outer Insulation", "Outer Insulation Extensions", "Centreline Length With Extensions", "Inlet", "Outlet", "Item Volume", "Diameter", "Btm Length", "Top Length", "Inner Radius", "Angle", "Bottom Extension", "Top Extension", "C1", "C2", "C3", "S1", "D1", "D2", "Specification", "Insulation Specification", "Insulation Specification Abbreviation", "Insulation Thickness", "Bottom of Pipe", "Top of Hanger", "Hanger Identification Abbreviation", "Order", "Level", "Elevation", "End Size(s)", "Length/Angle", "Notes", "Points", "Sex Type", "Number of Sides", "Back Fillet", "Front Fillet", "Width", "Depth", "Height", "Height #2", "Width #2", "Depth #2", "Quantity", "Straight", "Length", "Chamfer", "Hidden Detail", "Collar", "Offset", "Right Collar", "Right Diameter"}, {"CID", "PatternNumber.1", "Number Of Segments", "Diameter Type", "Angle Tolerance", "Mark Sides", "Leg Lengths", "Fixing Holes On Extension", "Square Outer Insulation", "Outer Insulation Extensions", "Centreline Length With Extensions", "Inlet", "Outlet", "Item Volume", "Diameter", "Btm Length", "Top Length", "Inner Radius", "Angle", "Bottom Extension", "Top Extension", "C1", "C2", "C3", "S1", "D1", "D2", "Specification", "Insulation Specification", "Insulation Specification Abbreviation", "Insulation Thickness", "Bottom of Pipe", "Top of Hanger", "Hanger Identification Abbreviation", "Order.1", "Level", "Elevation", "End Size(s)", "Length/Angle", "Notes", "Points", "Sex Type", "Number of Sides", "Back Fillet", "Front Fillet", "Width", "Depth", "Height", "Height #2", "Width #2", "Depth #2", "Quantity", "Straight", "Length.1", "Chamfer", "Hidden Detail", "Collar", "Offset", "Right Collar", "Right Diameter"}),
    ResultTable = Table.Combine({tempTable3})
in
    ResultTable

 

 

1 ACCEPTED SOLUTION

The following step in your query filters the `modelParts` list to just the first item:

    modelParts1 = modelParts{0},

 

If 'modelParts` contains the results of your calls to the API for each `id`, why do you limit the resulting list to just the first item? What happens when you delete the `modelParts1` step?

View solution in original post

4 REPLIES 4
v-lionel-msft
Community Support
Community Support

Hi @Anonymous ,

 

"All the calls seem to work, except the "each" is supponsed to go through all of the ids in the table and call the API, adding the returned data to one large table."

Are you saying that M query failed to call the API? Or does the program report no errors but does not meet your needs?

 

Best regards,
Lionel Chen

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Anonymous
Not applicable

The M query called the API but I want it to call it for the half dozen or so records I have in a table. Right now it only calls the API for the first record and completes.

 

@v-lionel-msft 

The following step in your query filters the `modelParts` list to just the first item:

    modelParts1 = modelParts{0},

 

If 'modelParts` contains the results of your calls to the API for each `id`, why do you limit the resulting list to just the first item? What happens when you delete the `modelParts1` step?

Anonymous
Not applicable

@tonmcg If I delete that line, I get an error that it can't conver type List to type Table

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

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