Forum Discussion
Referencing A Text String (URL) In A Power Query
I am using Excel and Quick Base. Quick Base allows querying data via URL. I have successfully set up and run a query in Excel Power Query from our Quick Base database.
Here is an example of what that Power Query looks like:
let
Source = Csv.Document(Web.Contents("https://hardermech.quickbase.com/db/jkii2h8?act=API_GenResultsTable&usertoken=usertoken&options=csv&clist=8.3.6&query={8.EX.410052}AND{29.EX.1}AND{31.XEX.6}AND{84.XEX.1}"
),[Delimiter=","]),
#"Promoted Headers" = Table.PromoteHeaders(Source, [PromoteAllScalars=true])
in
#"Promoted Headers"
Instead of hard coding the entire text string for the URL, I want to build up the text string (parameterize it) in an Excel cell so that I can reference various values in the spreadsheet, then pull that string into the query source statement above.
I have found some online resources for building a Power Query to reference a specific cell on a spreadsheet.
How do I then reference that parameter correctly in this Source statement?
If that's one cell parameter, you may name such cell
query it and use as parameter
let GetURL = Excel.CurrentWorkbook(){[Name="URLstring"]}[Content][Column1]{0}, Source = Csv.Document(Web.Contents(GetURL),[Delimiter=","]), #"Promoted Headers" = Table.PromoteHeaders(Source, [PromoteAllScalars=true]) in #"Promoted Headers"
If there are few parameters, idea is the same but you organize you parameter into Excel table, query it, combine value into one string and use to access web resource.
5 Replies
- SergeiBaklanDiamond Contributor
If that's one cell parameter, you may name such cell
query it and use as parameter
let GetURL = Excel.CurrentWorkbook(){[Name="URLstring"]}[Content][Column1]{0}, Source = Csv.Document(Web.Contents(GetURL),[Delimiter=","]), #"Promoted Headers" = Table.PromoteHeaders(Source, [PromoteAllScalars=true]) in #"Promoted Headers"
If there are few parameters, idea is the same but you organize you parameter into Excel table, query it, combine value into one string and use to access web resource.
- JonInPDXCopper Contributor
SergeiBaklan Fantastic! That worked perfectly. Thank you!
- SergeiBaklanDiamond Contributor
JonInPDX , you are welcome