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

The ultimate Microsoft Fabric, Power BI, Azure AI & SQL learning event! Join us in Las Vegas from March 26-28, 2024. Use code MSCUST for a $100 discount. Register Now

Reply
tvoss
Regular Visitor

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 @tvoss ,

 

"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.

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?

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

Helpful resources

Announcements
Fabric Community Conference

Microsoft Fabric Community Conference

Join us at our first-ever Microsoft Fabric Community Conference, March 26-28, 2024 in Las Vegas with 100+ sessions by community experts and Microsoft engineering.

February 2024 Update Carousel

Power BI Monthly Update - February 2024

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

Fabric Career Hub

Microsoft Fabric Career Hub

Explore career paths and learn resources in Fabric.

Fabric Partner Community

Microsoft Fabric Partner Community

Engage with the Fabric engineering team, hear of product updates, business opportunities, and resources in the Fabric Partner Community.

Top Solution Authors