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

Select all contiguous cells
Pressing Ctrl+* (asterisk) will select the "current region" - all contiguous cells in all directions.

Comfy

Well-known Member
Joined
Dec 21, 2009
Messages
3,386
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,191,587
Messages
5,987,510
Members
440,098
Latest member
MickyMouse123

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
Top