Forum Discussion
Need suggestion on PowerBI-MQuery Looping for calling the API
It is possible to explicitly write the entire power query to achieve this. But if you are new to power query, I would suggest the following..
Step 1: Store the subscriptions ids in some file (csv, excel etc..) or in a database table.
Step 2: Import the list of subscription ids into Power BI desktop. Copy the power query and paste it in a text editor and keep it aside for future use.
Step 3: Take any one subscription ID as a sample and create a new power query to call the API using this subscription id and fetch the response.
Step 4: Copy the power query generated in Step 3 and keep it aside for future use.
Step 5: Open a blank query, paste the Power Query generated in Step 2.
Step 6: Open this query in advance editor, add a step to add a new column using Table.AddColumn() function.
Step 7: While adding the column, after giving the new column a name like "API Response", after the "each", paste the second power query generated in Step 5.
Step 8: Instead of the subscription ID that was hardcoded in the power query in Step 7's API call, generate the API call for each subscription ID using string concatenation. For example, "API Prefix part" + Record.Field(_,[subsriptionid]) + "API suffix part".
Step 9: If you have done correctly till now, upon execution, the query will fetch the API response for each subscription id and put the response of each subscription id in a table cell.
Step 10: Expand the column contents, you will have your output.
If you have any trouble, please reply with two autogenerated power queries (in Step 2 and 3), I will combine them and post the completed query. Unless you give some code, it is difficult to help.