相对日期筛选器 (IsInPreviousNMonths) 未刷新
Relative Date filter (IsInPreviousNMonths) is not refreshed
我正在使用以下查询(在直接查询模式下连接到 SQL 数据库时)获取过去 12 个月的预约:
Table.SelectRows(dbo_ReportAppointmentsView, each Date.IsInPreviousNMonths([Date], 12))
它工作得很好,正在生成 SQL 查询,其中的 where 子句如下:
where convert(date, [_].[Date]) >= convert(datetime2, '2015-11-01 00:00:00') and convert(date, [_].[Date]) < convert(datetime2, '2016-11-01 00:00:00'))
问题是,当当前月份发生变化时(11 月 -> 12 月),它仍在生成具有完全相同日期的 SQL 查询。
我希望日期为“2015-12-01”和“2016-12-01”以显示前 12 个月的数据。
在 Power BI 桌面中按 "Refresh" 按钮会有所帮助,但如果我希望报表自动显示正确的数据,这显然不是一个可维护的解决方案。
这是错误还是预期行为?
如果说 "Direct Query mode" 你的意思是 "Native Query",那么这不是最佳做法,应该避免。
除此之外,尝试将 Date.IsInPreviousNMonths
替换为
LocalDT = Date.LocalNow() //May be replaces with desired #date(2016, 11, 25) and likewise
ThisMonthStart = #date(Date.Year(LocalDT), Date.Month(LocalDT), 1),
CompareDate = Date.AddMonths(ThisMonthStart, -12),
Table.SelectRows(dbo_ReportAppointmentsView, each [Date] >= CompareDate)
看看它是否在查询中生成另一个日期。
如果您确实使用了本机查询,那么这可能是与此模式相关的错误。
所有检查特定时间段内相对于系统日期(时间)的日期(时间)的函数,应解释为“.... 最后刷新”。
在我看来,这是预期的行为,即使 运行 是直接查询模式:在上次刷新时使用查询定义访问最新数据。
我的建议是在您的 SQL 数据库中创建一个包含当前系统日期(时间)的字段(或者如果它已经可用就使用它)和 select 您的数据基于该字段的值。
此行为似乎是 known issue。
The behavior you're observing when using Direct Query against SQL is a
known issue with the legacy Direct Query architecture. We will be
moving SQL Direct Query to a new architecture over the next few
months, but until then there's unfortunately no workaround besides
manually refreshing.
我正在使用以下查询(在直接查询模式下连接到 SQL 数据库时)获取过去 12 个月的预约:
Table.SelectRows(dbo_ReportAppointmentsView, each Date.IsInPreviousNMonths([Date], 12))
它工作得很好,正在生成 SQL 查询,其中的 where 子句如下:
where convert(date, [_].[Date]) >= convert(datetime2, '2015-11-01 00:00:00') and convert(date, [_].[Date]) < convert(datetime2, '2016-11-01 00:00:00'))
问题是,当当前月份发生变化时(11 月 -> 12 月),它仍在生成具有完全相同日期的 SQL 查询。 我希望日期为“2015-12-01”和“2016-12-01”以显示前 12 个月的数据。
在 Power BI 桌面中按 "Refresh" 按钮会有所帮助,但如果我希望报表自动显示正确的数据,这显然不是一个可维护的解决方案。 这是错误还是预期行为?
如果说 "Direct Query mode" 你的意思是 "Native Query",那么这不是最佳做法,应该避免。
除此之外,尝试将 Date.IsInPreviousNMonths
替换为
LocalDT = Date.LocalNow() //May be replaces with desired #date(2016, 11, 25) and likewise
ThisMonthStart = #date(Date.Year(LocalDT), Date.Month(LocalDT), 1),
CompareDate = Date.AddMonths(ThisMonthStart, -12),
Table.SelectRows(dbo_ReportAppointmentsView, each [Date] >= CompareDate)
看看它是否在查询中生成另一个日期。
如果您确实使用了本机查询,那么这可能是与此模式相关的错误。
所有检查特定时间段内相对于系统日期(时间)的日期(时间)的函数,应解释为“.... 最后刷新”。
在我看来,这是预期的行为,即使 运行 是直接查询模式:在上次刷新时使用查询定义访问最新数据。
我的建议是在您的 SQL 数据库中创建一个包含当前系统日期(时间)的字段(或者如果它已经可用就使用它)和 select 您的数据基于该字段的值。
此行为似乎是 known issue。
The behavior you're observing when using Direct Query against SQL is a known issue with the legacy Direct Query architecture. We will be moving SQL Direct Query to a new architecture over the next few months, but until then there's unfortunately no workaround besides manually refreshing.