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