Power Query: reading data from web and populating query url with parameters from table

chilly_bang

Board Regular
Joined
Jun 17, 2016
Messages
57
Hi
I'm using Power Query to read some data through a web API. The API is queried with an URL containing some paramaters and responses with data. The query URL looks like:
Code:
http://api.semrush.com/?type=url_organic&key=$key&display_limit=10&export_columns=Ph,Po,Ur&url=http://example.com/&database=de&display_filter=-Ph|Co|test
The workaround here is simple: Power Query → read data from web → input url → done


Now i want to populate the query url with parameters from an Excel table, so the query urls will look like:
Code:
"http://api.semrush.com/?type=url_organic&key=$key&display_limit=10&export_columns=Ph,Po,Ur&url="&[B]A2[/B]&"&database="&[B]B2[/B]&"&display_filter=-Ph|Co|test"
Could somebody point me to the correct workflow and syntax, so i reach my goal?

thanks and best regards


 
Last edited:

Excel Facts

Waterfall charts in Excel?
Office 365 customers have access to Waterfall charts since late 2016. They were added to Excel 2019.
Using your example of Parameters in A2:B2 and assuming headers in A1:B1

Turn this into a table and pull into Power Query (I have called the Table and resulting Query "tParam"):


Excel 2010
AB
1urldatabase
2http://example.com/de
3
Sheet1


Rich (BB code):
let
    Source = Excel.CurrentWorkbook(){[Name="tParam"]}[Content],
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"url", type text}, {"database", type text}})
in
    #"Changed Type"


You can then refer to these parameters in your main Query:

Rich (BB code):
let
    dBase = tParam[database]{0},
    url = tParam{0},
    Source = "http://api.semru...lay_filter=-Ph|Co|test"
in
    Source
[/code]
 
Upvote 0

Forum statistics

Threads
1,214,983
Messages
6,122,583
Members
449,089
Latest member
Motoracer88

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top