apache2.4.6支不支持jsp_Web.Contents()的数据源为什么不支持计划刷新?

我大意了,没有防备,居然在Web.Contents()的第一参数里传变量。 Jacob Dong,公众号:Jacob的BI贴士优化SharePoint List查询速度,刷新时间缩短数倍

    当你用Power Query做完网抓,开开心心发布到Power BI Service上。然后点开数据集开始配置计划刷新。突然就傻眼了,怎么……不能配置计划刷新了?

9ec5b29fb5f4cdef810c8eb61309c613.png

12afbea308d7c9be50fb7065c858c66e.png

于是打开了解详细信息的页面https://aka.ms/dynamic-data-sources:

d081bfde05e61af90d5cc17fba0a6ad5.png

7486f35f0ba745754eca1f40ebacbb68.png

看懂了吗?

不管看得懂看不懂,我直接告诉你,这问题就出在Web.Contents()的第一参数上。

就拿昨天的文章举例,我在自定义函数中这么写的:

Web.Contents(            "https://" & Domain & ".sharepoint.com/sites/" & SharePointSiteName & "/_api/web/lists/            GetByTitle('" & ListName & "')/            items?$skipToken=Paged=TRUE%26p_ID="& Text.From([Column1]) & "&$top=5000",            [Headers = [Accept = "application/json"]]          )

    好家伙,直接往Web.Contents()的第一参数里传递了4个变量:

Domain,SharePointSiteName,ListName,Text.From(Column1)。

    我原本是打算封装起来傻瓜式使用的。但是问题在于,对于已发布的数据集进行刷新时,Power BI服务会先对M代码进行静态分析,确定数据集中的数据源是什么,凭据是否正确。所以变量还没有传就已经在静态分析这一步失败了。

解决方法

    Web.Contents()只检查基url,可以把含变量的部分拆分出来,写进RelativePath参数里拼接url。不过对于我这个案例,看来是行不通了,因为domain是基url的一部分。(如果不对希望高手可以指出)。

    先写下完整的SharePoint网站地址:

Web.Contents(            "https://.sharepoint.com/sites/",            [Headers = [Accept = "application/json"]]          )

将之后的url部分写进RelativePath:

Web.Contents(            "https://.sharepoint.com/sites/",            [              Headers = [Accept = "application/json"],              RelativePath="_api/web/lists/GetByTitle('')/items?$skipToken=Paged=TRUE%26p_ID="&Text.From([Column1])&"&$top=5000"            ]          )

这样,这个数据源就可以被刷新了。

参考文章:

  • https://blog.crossjoin.co.uk/2016/08/16/using-the-relativepath-and-query-options-with-web-contents-in-power-query-and-power-bi-m-code/

  • https://blog.crossjoin.co.uk/2016/08/23/web-contents-m-functions-and-dataset-refresh-errors-in-power-bi/

  • https://blog.crossjoin.co.uk/2019/04/25/skip-test-connection-power-bi-refresh-failures/

  • https://aka.ms/dynamic-data-sources

  • http://blog.datainspirations.com/2018/02/17/dynamic-web-contents-and-power-bi-refresh-errors/

  • http://blog.datainspirations.com/2018/05/12/revisiting-dynamic-web-contents/

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值