PowerQuery use a cell values in a URL

时光总嘲笑我的痴心妄想 提交于 2019-12-11 14:46:43

问题


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

回答1:


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

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


来源:https://stackoverflow.com/questions/49281763/powerquery-use-a-cell-values-in-a-url

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!