表达式:评估期间遇到了环状参考。 - 使用Power查询中的自定义功能网络日

发布于 2025-02-08 21:39:19 字数 1057 浏览 1 评论 0原文

我已经从空白查询中创建了一个自定义功能,以计算出不包括假期和周末的天数,该功能

   Query1 = (StartDate as date, EndDate as date) as number => 

let 
DateList = List.Dates(StartDate, Number.From(EndDate - StartDate) , #duration(1, 0, 0, 0)),
RemoveWeekends = List.Select(DateList, each Date.DayOfWeek(_, Day.Monday) < 5),
RemoveHolidays = List.RemoveItems(RemoveWeekends, Holidays),
CountDays = List.Count(RemoveHolidays)
in
CountDays,
   Custom1 = Query1
in
   Custom1 

在我的计算机上的文件中都在工作,但是问题是当我团队中的其他任何人都在尝试使用那里有查询的文件。我们正在遇到错误&lt; expression.Error:评估期间遇到了环状参考。&gt;

我试图追踪步骤,并找出何时发生错误,并且总是指向自定义功能。 请帮助我,我需要尽快修复它,以便我的团队可以使用它。

function screen

函数之前的

日历

”使用此YouTube指南创建函数: https://www.youtube.com/watch = v = v = v = E2IC432NVHY

I have created a custom function from a blank query to calculate the number of days excluding holidays and the weekends, the function is below

   Query1 = (StartDate as date, EndDate as date) as number => 

let 
DateList = List.Dates(StartDate, Number.From(EndDate - StartDate) , #duration(1, 0, 0, 0)),
RemoveWeekends = List.Select(DateList, each Date.DayOfWeek(_, Day.Monday) < 5),
RemoveHolidays = List.RemoveItems(RemoveWeekends, Holidays),
CountDays = List.Count(RemoveHolidays)
in
CountDays,
   Custom1 = Query1
in
   Custom1 

Everything is working in the file on my computer, but the issue is when anyone else from my team is trying to use the file with queries there. We are getting error <Expression.Error: A cyclic reference was encountered during evaluation.>

I've tried to trace steps and find out when the error is occurring and it's always pointing at the custom function.
Please help me, I need to fix it asap so my team can use this.

Function screen

Calendar before function

Calendar after function

I was using this youtube guide to create function: https://www.youtube.com/watch?v=e2ic432NvhY

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

-黛色若梦 2025-02-15 21:39:23

尝试将功能更改为

(StartDate as date, EndDate as date) as number => 
let DateList = List.Dates(StartDate, Number.From(EndDate - StartDate) , #duration(1, 0, 0, 0)),
RemoveWeekends = List.Select(DateList, each Date.DayOfWeek(_, Day.Monday) < 5),
RemoveHolidays = List.RemoveItems(RemoveWeekends, Holidays),
CountDays = List.Count(RemoveHolidays)
in CountDays 

那时,假设假期是一个查询,并有一些日期列表,

= {#date(2022,6,15),#date(2022,1,18)}

然后

= Table.AddColumn(#"Changed Type", "Custom", each NetWorkDays([StartDate],[EndDate]))

工作正常

try changing your function to

(StartDate as date, EndDate as date) as number => 
let DateList = List.Dates(StartDate, Number.From(EndDate - StartDate) , #duration(1, 0, 0, 0)),
RemoveWeekends = List.Select(DateList, each Date.DayOfWeek(_, Day.Monday) < 5),
RemoveHolidays = List.RemoveItems(RemoveWeekends, Holidays),
CountDays = List.Count(RemoveHolidays)
in CountDays 

then, assuming Holidays is a query with some list of dates like

= {#date(2022,6,15),#date(2022,1,18)}

then

= Table.AddColumn(#"Changed Type", "Custom", each NetWorkDays([StartDate],[EndDate]))

works fine

彼岸花ソ最美的依靠 2025-02-15 21:39:23

感谢大家的快速答案。
我的问题是,首先,我基于节日和日历列表创建了自定义功能,然后也在日历中使用了它。当我从日历查询中删除自定义功能,仅留下一周的开始日期,结束日期和周数,它再次开始工作。

Thanks everyone for such quick answers.
My issue was that first I've created custom function based on list of holidays and calendar and then i've used it in calendar as well. When I removed custom function from the calendar query, leaving only starting date of the week, ending date and week number it started to work again.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文