如何在Power Bi Advanced编辑器中将今天日期作为动态输入日期传递?

时间:2020-01-29 11:14:00

标签: powerbi powerbi-desktop powerbi-embedded powerbi-datasource powerbi-custom-visuals

我正在尝试在高级查询编辑器中传递截至今天的日期值

let 
    Source = GoogleBigQuery.Database(null),
    #"apple-5a221" = Source{[Name="apple-5a221"]}[Data],
    analytics_187358390_Schema = #"apple-5a221"{[Name="analytics_187358390",Kind="Schema"]}[Data],
    events_intraday_20200129_Table = analytics_187358390_Schema{[Name="events_intraday_20200129",Kind="Table"]}[Data]
in
    events_intraday_20200129_Table

1 个答案:

答案 0 :(得分:0)

要传递“今天”动态日期:

花了一个小时后,我找到了一个解决方案[Name="events_intraday_ "&datetime&" ”,并声明了datetime = DateTime.ToText(DateTime.LocalNow(), "yyyyMMdd")

let 
    datetime = DateTime.ToText(DateTime.LocalNow(), "yyyyMMdd"),
    Source = GoogleBigQuery.Database(null),
    #"apple-5a221" = Source{[Name="apple-5a221"]}[Data],
    analytics_187358390_Schema = #"apple-5a221"{[Name="analytics_187358390",Kind="Schema"]}[Data],
    events_intraday_20200129_Table = analytics_187358390_Schema{[Name="events_intraday_"&datetime&"",Kind="Table"]}[Data]
in
    events_intraday_20200129_Table

要传递昨天的动态日期:

datetime = Date.ToText(Date.AddDays(Date.From(DateTime.FixedLocalNow()),-1),“ yyyyMMdd”)

let
    datetime =  Date.ToText(Date.AddDays(Date.From(DateTime.FixedLocalNow()),-1), "yyyyMMdd"),
    Source = GoogleBigQuery.Database(null),
    #"prutopia-5a221" = Source{[Name="apple-5a221"]}[Data],
    analytics_187358390_Schema = #"apple-5a221"{[Name="analytics_187358390",Kind="Schema"]}[Data],
    events_datetime_Table = analytics_187358390_Schema{[Name="events_"&datetime&"",Kind="Table"]}[Data]
in
    events_datetime_Table