在Power BI中获取数据时,请在REST API调用中指定今天的日期

时间:2019-05-22 10:44:03

标签: powerbi powerbi-desktop powerbi-datasource

我正在使用Power BI并从REST API获取数据。我想指定结果的日期范围为从指定的结束日期到今天的日期。正确的语法是什么?我已经尝试过TODAY(),但似乎无法正常工作,需要将日期时间设置为以下格式。

Source = Json.Document(Web.Contents("https://mywebsite.com/v1/site/1/records?startDate=2019-05-10T00:00:00.000Z&endDate=TODAY()"), 65001)

感谢您的帮助

1 个答案:

答案 0 :(得分:1)

TODAY()函数是DAX函数,而这是M代码,您应该使用相应的date functions。另外,您将TODAY()放在引号之间,这样它将按原样发送。

您可以将代码更改如下:

Source = Json.Document(Web.Contents("https://mywebsite.com/v1/site/1/records?startDate=2019-05-10T00:00:00.000Z&endDate=" & Date.ToText(DateTime.Date(DateTime.LocalNow()), "yyyy-MM-dd") & "T00:00:00.000Z")), 65001)