0

我有一个查询,我想按我创建的新日期列进行过滤。

基本上,任何比该日期早 42 天的都可以接受。

我试过按日期进行过滤,然后将其减去 42,但它不起作用?

let
    #"SQL-JM" = let
    Source = Sql.Databases("xxx.xxx.xxx.xxx"),
    MNH = Source{[Name="DBT"]}[Data],
    #"DBO-JM" = DBT{[Schema="dbo",Item="DBO-JM"]}[Data]
in
    #"DBO-JM",
    #"Added Custom1" = Table.AddColumn(#"DBO-JM", "Start_of_QTR", each Date.StartOfQuarter(DateTime.LocalNow())),
in
    #"Filtered Rows"
4

2 回答 2

2

如果我正确理解您的任务,您根本不需要自定义列。

我会这样做:

let
    #"SQL-JM" = let
    Source = Sql.Databases("xxx.xxx.xxx.xxx"),
    MNH = Source{[Name="DBT"]}[Data],
    #"DBO-JM" = DBT{[Schema="dbo",Item="DBO-JM"]}[Data],
    GetFilterDate = Date.From(Date.StartOfQuarter(DateTime.LocalNow())), //You can use any logic to get that date
    FilterRows = Table.SelectRows(#"DBO-JM", each [DateStamp] < GetFilterDate) //You can also add some modifications to GetFilterDate using each row's values, if you need
in
    FilterRows
于 2017-01-18T22:36:29.220 回答
1

假设您要按DateStamp早于 42 天的列进行过滤Start_of_QTR,您可以在 #"Added Custom1" 行之后添加以下行:

#"Filtered Rows" = Table.SelectRows(#"Added Custom1", each [DateStamp] < Date.AddDays([Start_of_QTR], -42))
于 2017-01-18T04:30:54.727 回答