0

我是使用 Excel 编写 SQL 查询的新手,我将解释我在做什么然后我做了什么我试图从 YahooFinance 导入表格数据(见下面的链接)

https://au.finance.yahoo.com/calendar/earnings?from=2021-08-15&to=2021-08-21&day=2021-08-16

所以目前我遵循了一个参数化的 URL,然后将 URL 更改为最后一个日期(在 HTTP 链接中),然后生成一个包含所有所述数据的新表。问题不是每个日期都有我需要的数据。有几个原因 1. 周末不包含收入数据,链接中看到的其他日子不包含数据。我要做的基本上是让 SQL 说 IF - 表 0(或来自 yahoo Finance 的公司数据)不存在,然后移动到下一个行项目,并继续在列表中生成数据。通常,当在网站的表中未找到“符号”时,错误作为表达式错误出现

目前的代码是这样的

let GetResults=(URL) =>
let
    Source = Web.Page(Web.Contents(URL)),
    Data0 = Source{0}[Data],
    #"Changed Type" = Table.TransformColumnTypes(Data0,{{"Symbol", type text}, {"Company", type text}, {"Earnings call time", type text}, {"EPS estimate", type text}, {"Reported EPS", type text}, {"Surprise (%)", type text}})
in
    #"Changed Type"

in GetResults

其中 URL 定义为

let
    Source = Excel.CurrentWorkbook(){[Name="Table15"]}[Content],

    #"Changed Type" = Table.TransformColumnTypes(Source,{{"URL", type text}}),
    #"Added Custom" = Table.AddColumn(#"Changed Type", "Results Data", each fGetWikiResults([URL])),
    #"Expanded Results Data" = Table.ExpandTableColumn(#"Added Custom", "Results Data", {"Symbol", "Company", "Earnings call time", "EPS estimate", "Reported EPS", "Surprise (%)"}, {"Results Data.Symbol", "Results Data.Company", "Results Data.Earnings call time", "Results Data.EPS estimate", "Results Data.Reported EPS", "Results Data.Surprise (%)"}),
    #"Filtered Rows" = Table.SelectRows(#"Expanded Results Data", each true)
in
    #"Filtered Rows"

每个查询都相互反馈,这远远超出了我自己的知识,但这是文件需要的最后一点实际代码,其余的我可以在 excel 中完成所有在你说之前!是的,我需要去学习 SQL(我已经推迟了很长时间,因为我以前能够使用 excel 解决方法)非常感谢你回答这个问题的人我很感激

Thank you for your help :) 
4

0 回答 0