I am new to Power Query and have just learned how to pull in data from an external API using it. The thing is, that I actually need to make multiple calls to the same API. For example:
- http:://my-external-api.com/get-data/set-one?api_key=1234
- http:://my-external-api.com/get-data/set-two?api_key=1234
- http:://my-external-api.com/get-data/set-three?api_key=1234
- Etc.
In theory, this is how I imagine accomplishing this:
Step #1: Create an array of all the sets of data I want for my api.
E.g., setData = ['set-one', 'set-two', 'set-three', ...]
Step #2: Create a URL with a variable in it.
E.g., url = "http:://my-external-api.com/get-data/" & setVar & "?api_key=1234"
Step #3: Loop through this array and URL variable, outputting the data into Power Query.
The thing is, being new to Power Query I do not know how to do this. I have learned a bit of the basics of M Code, but I still am having a hard time figuring out how to do this.
Any ideas?
Thanks.
- List item
CodePudding user response:
There are a few ways of looping in PQ ranging from recursive functions to List.Generate(). In this case, I would go with List.Generate() and there is an excellent guide here: