You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Excel中PowerQuery用Date.IsInCurrentWeek报错:Function转Logical失败

PowerQuery 日期判断报错解决方法

错误原因分析

你的公式存在两处问题,导致触发类型不匹配报错:

  1. each的位置错误:你将each放在if语句之后,使得each Date.IsInCurrentWeek([Application Date])被识别为一个函数,而if需要的是逻辑布尔值,因此出现类型转换失败。
  2. 布尔值与字符串错误比较:Date.IsInCurrentWeek返回的是原生布尔值(true/false),无需与字符串"FALSE"对比,直接用布尔值判断即可。

正确写法

方法1:用each包裹整个判断逻辑

= Table.AddColumn(#"Reordered Columns", "App.CurrentWeek", each if Date.IsInCurrentWeek([Application Date]) then 1 else 0)

方法2:用(row)显式指代当前行

= Table.AddColumn(#"Reordered Columns", "App.CurrentWeek", (row) => if Date.IsInCurrentWeek(row[Application Date]) then 1 else 0)

扩展到月、年度统计

只需替换对应的日期判断函数即可:

  • 当月判断:Date.IsInCurrentMonth
  • 当年判断:Date.IsInCurrentYear

示例(添加当月统计列):

= Table.AddColumn(#"Added CurrentWeek", "App.CurrentMonth", each if Date.IsInCurrentMonth([Application Date]) then 1 else 0)

内容的提问来源于stack exchange,提问作者RickyRoawsay

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.14 11:52:03