在查询编辑器(Power BI 或 Power Query)中引用另一个 Table

Reference another Table in the Query Editor (PowerBI or PowerQuery)

我正在 运行查询以更新 PowerBI 中的历史数据 table。此更新查询调用 Adob​​e Analytics API,并根据我指定的日期范围提取数据。

因为我希望它尽快 运行,所以我只想查询我的历史数据 table 中还没有的数据。我可以根据 Date.Time.LocalNow() 确定此查询的结束日期。

#date(Date.Year(DateTime.LocalNow()), Date.Month(DateTime.LocalNow()), Date.Day(DateTime.LocalNow())-1)

但是,我遇到的问题是设定开始日期。理想情况下,我想从我的数据模型中的 table 中获取 MaxDate,并在查询编辑器中使用此值作为我的开始日期。

我该怎么做?

更新 1 - 完整代码如下

let
Source = AdobeAnalytics.Cubes()
myreportsuiteid = Source{[Id="myreportsuiteid"]}[Data],
#"Added Items" = Cube.Transform(myreportsuiteid,
    {
        {Cube.AddAndExpandDimensionColumn, "DateGranularity", {"year", "month", "day"}, {"Date Granularity.Level 1: Year", "Date Granularity.Level 2: Month", "Date Granularity.Level 3: Day"}},
        {Cube.AddAndExpandDimensionColumn, "lasttouchchannel", {"lasttouchchannel"}, {"Last Touch Marketing Channel"}},        
        {Cube.AddMeasureColumn, "Unique Visitors", "uniquevisitors"},
        {Cube.AddMeasureColumn, "Visits", "visits"},
        {Cube.ApplyParameter, "DateRange", {#date(Date.Year(List.Max(Union[Date])), Date.Month(List.Max(Union[Date])), Date.Day(List.Max(Union[Date]))+1), #date(Date.Year(DateTime.LocalNow()), Date.Month(DateTime.LocalNow()), Date.Day(DateTime.LocalNow())-1)}},
        {Cube.ApplyParameter, "Segment", {{"s300000554_5ae201be22fa9950dcdbcd92"}}}
    })
in
    #"Added Items"

更新 2

工作代码

Daily US 是 table 通过查询编辑器

创建的
let
Source = AdobeAnalytics.Cubes(),
todaysDate = Date.AddDays(DateTime.Date(DateTime.LocalNow()),-1),
maxDate = Date.AddDays(List.Max(#"Daily US"[Date]),1),
myreportsuiteid = Source{[Id="myreportsuiteid "]}[Data],

错误代码

Union US 是 table 通过 Union US = DISTINCT(UNION('Seeker US','Daily US'))[=44= 在查询编辑器之外创建的]

let
Source = AdobeAnalytics.Cubes(),
todaysDate = Date.AddDays(DateTime.Date(DateTime.LocalNow()),-1),
maxDate = Date.AddDays(List.Max(#"Union US"[Date]),1),
myreportsuiteid = Source{[Id="myreportsuiteid "]}[Data],

如果您要为 MaxDate 引用的列名为 Union[Date],那么您应该能够使用 List.Max 从该列中获取最大值。

试试这个:

let
Source = AdobeAnalytics.Cubes(),
MaxDate = List.Max(Union[Date]),
TodaysDate = DateTime.Date(DateTime.LocalNow()),
myreportsuiteid = Source{[Id="myreportsuiteid"]}[Data],
#"Added Items" = Cube.Transform(myreportsuiteid,
    {
        {Cube.AddAndExpandDimensionColumn, "DateGranularity", {"year", "month", "day"}, {"Date Granularity.Level 1: Year", "Date Granularity.Level 2: Month", "Date Granularity.Level 3: Day"}},
        {Cube.AddAndExpandDimensionColumn, "lasttouchchannel", {"lasttouchchannel"}, {"Last Touch Marketing Channel"}},        
        {Cube.AddMeasureColumn, "Unique Visitors", "uniquevisitors"},
        {Cube.AddMeasureColumn, "Visits", "visits"},
        {Cube.ApplyParameter, "DateRange", {MaxDate, TodaysDate}},
        {Cube.ApplyParameter, "Segment", {{"s300000554_5ae201be22fa9950dcdbcd92"}}}
    })
in
    #"Added Items"