如何在字符串中找到一年?
我尝试编写一个自定义功能,该功能将在给定的字符串中找到当前或明年的当前功能。假设我在name
列中有一个字符串:a2022_new_accruals.xlsx
。如果不是,我需要返回1,如果不是,则null
。我写了此功能,但它给了我错误:
= if Text.Contains([Name], Date.ToText(Date.Year(DateTime.LocalNow()),"yyyy")) or Text.Contains([Name], Date.ToText(Date.AddYears(Date.Year(DateTime.LocalNow()),1),"yyyy")) then 1 else null
错误:
expression.error:无法将函数类型的值转换为日期类型
I try to write a custom function which is going to find a current or next year in a given string. Let's say I have a string in a Name
column: A2022_new_accruals.xlsx
. I need to return 1 if it's true, null
if it's not. I wrote this function but it gives me error:
= if Text.Contains([Name], Date.ToText(Date.Year(DateTime.LocalNow()),"yyyy")) or Text.Contains([Name], Date.ToText(Date.AddYears(Date.Year(DateTime.LocalNow()),1),"yyyy")) then 1 else null
Error:
Expression.Error: Cannot convert value of Function type to Date type
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
尝试
try