Power查询高级编辑器错误-PowerBI至Excel

时间:2019-04-30 15:43:47

标签: excel powerquery m

下面的代码是在Power BI中自动生成的,想要在excel中复制它。 但是,有一个表达错误“导入Html.Table与导出不匹配。您错过了模块引用吗?”。

我将代码从PowerBI高级编辑器M代码复制并粘贴到下面的Excel高级编辑器

let
    Source = Web.BrowserContents("http://edge.pse.com.ph/disclosureData/dividends_and_rights_info_form.do"),
    #"Extracted Table From Html" = Html.Table(Source, {{"Company Name", "DIV[id='dataList'] > TABLE.list:nth-child(7) > TBODY > TR > :nth-child(1)"}, {"Type of Security", "DIV[id='dataList'] > TABLE.list:nth-child(7) > TBODY > TR > :nth-child(2)"}, {"Type of Dividend", "DIV[id='dataList'] > TABLE.list:nth-child(7) > TBODY > TR > :nth-child(3)"}, {"Dividend Rate", "DIV[id='dataList'] > TABLE.list:nth-child(7) > TBODY > TR > :nth-child(4)"}, {"Ex-dividend Date", "DIV[id='dataList'] > TABLE.list:nth-child(7) > TBODY > TR > :nth-child(5)"}, {"Record Date", "DIV[id='dataList'] > TABLE.list:nth-child(7) > TBODY > TR > :nth-child(6)"}, {"Payment date", "DIV[id='dataList'] > TABLE.list:nth-child(7) > TBODY > TR > :nth-child(7)"}, {"Circular Number", "DIV[id='dataList'] > TABLE.list:nth-child(7) > TBODY > TR > :nth-child(8)"}}, [RowSelector="DIV[id='dataList'] > TABLE.list:nth-child(7) > TBODY > TR"]),
    #"Changed Type" = Table.TransformColumnTypes(#"Extracted Table From Html",{{"Company Name", type text}, {"Type of Security", type text}, {"Type of Dividend", type text}, {"Dividend Rate", type text}, {"Ex-dividend Date", type date}, {"Record Date", type date}, {"Payment date", type date}, {"Circular Number", type text}})
in
    #"Changed Type"

整个报表是在excel中创建的。 最好在excel中获取表,因为powerBI中没有某些必需的功能。

1 个答案:

答案 0 :(得分:0)

尽管PowerQuery和PowerBI非常相似,但是某些代码命令有所不同。

我建议不要将powerBI代码直接复制粘贴到PQ中,而建议直接在PQ中完成(至少某些)步骤。假设您拥有Excel 2016或更高版本,我相信以下代码应该可以在PQ中为您工作:

let
    Source = Web.Page(Web.Contents("http://edge.pse.com.ph/disclosureData/dividends_and_rights_info_form.do")),
    Data = Source{0}[Data],
    #"Changed Type" = Table.TransformColumnTypes(Data,{{"Company Name", type text}, {"Type of Security", type text}, {"Type of Dividend", type text}, {"Dividend Rate", type text}, {"Ex-Dividend Date", type date}, {"Record Date", type date}, {"Payment Date", type date}, {"Circular Number", type text}})
in
    #"Changed Type"

如果您使用的PQ版本较旧,则可能需要逐步完成连接网站的手动步骤,以便生成正确的代码。 (我不知道我的PQ生成的Web连接代码在旧版PQ中是否可行。)