Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
760 views
in Technique[技术] by (71.8m points)

excel - PowerQuery use a cell values in a URL

I have the following PowerQuery code. Which collects some data from MSFT in yahoo finance.

I have a cell A1 for example which I would like to put MSFT, GOOG or another symbol. How can I change it so that when I change A1 it will automatically redownload for the new symbol?

let  Quelle = Web.Page(Web.Contents("https://finance.yahoo.com/q/bs?s=MSFT+Balance+Sheet&annual")),

    Data = Quelle{1}[Data],

    FirstRowHeader = Table.PromoteHeaders(Data)

in  FirstRowHeader

Using; $A$1 did not work.

https://finance.yahoo.com/q/bs?s=$A$1+Balance+Sheet&annual
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

As explained in the answer to this question, you can load in a cell value if you make it a named range.

The first step is to name your cell A1. Let's name it Ticker. You can name it by typing in the name in the upper left box when the cell is selected

Named Range

Then your query will look like this:

let
    Ticker = Excel.CurrentWorkbook(){[Name="Ticker"]}[Content]{0}[Column1],
    Quelle = Web.Page(Web.Contents("https://finance.yahoo.com/q/bs?s="&Ticker&"+Balance+Sheet&annual")),
    Data = Quelle{1}[Data],
    FirstRowHeader = Table.PromoteHeaders(Data)
in  FirstRowHeader

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...