简体   繁体   English

Sumif Excel函数错误

[英]Sumif Excel Function Error

I'm trying to calculate the days that an employee had an overtime; 我正在尝试计算员工加班的天数; but the function keeps give an error function. 但该功能始终提供错误功能。 I tried after searching use (;) instead of (,); 我在搜索后使用(;)代替(,); but still keep getting the error. 但仍然会继续出现错误。

The function: 功能:

=SUMIFS(LeaveTracker[Days],LeaveTracker[Employee Name],valSelEmployee,WEEKDAY(LeaveTracker[Start Date]),">5",WEEKDAY(LeaveTracker[End Date]),">5",LeaveTracker[Type of Leave],'Leave Types'!B8)

The Error message: The formula you typed contains an error. 错误消息:您键入的公式包含错误。

As I wrote in my comment, criteria_range arguments need to be ranges. 正如我在评论中所写, criteria_range参数必须是范围。 You have two which are not: WEEKDAY(LeaveTracker[Start Date]) and WEEKDAY(LeaveTracker[End Date]) do not return a range. 您有两个不是: WEEKDAY(LeaveTracker[Start Date])WEEKDAY(LeaveTracker[End Date])不返回范围。 They returns an array of weekday numbers. 他们返回一个工作日数字数组。 Hence your error. 因此,您的错误。

You could add two helper columns containing just the Weekday number referenced to start and end date, and then use those columns for the criteria_range in place of what you have. 您可以添加两个助手列,其中仅包含引用到开始日期和结束日期的工作日编号,然后将这些列用作criteria_range的位置。

So add a column named StartWeekDay with the formula: =WEEKDAY([@[Start Date]]) and similarly add a column named EndWeekDay 因此,添加具有以下公式的名为StartWeekDay的列: =WEEKDAY([@[Start Date]]) StartWeekDay =WEEKDAY([@[Start Date]])并类似地添加名为EndWeekDay的列

Then you can use SUMIFS : 然后,您可以使用SUMIFS

=SUMIFS(LeaveTracker[Days],LeaveTracker[Employee Name],valSelEmployee,(LeaveTracker[StartWeekDay]),">5",(LeaveTracker[EndWeekDay]),">5",LeaveTracker[Type of Leave],'Leave Types'!B8)

Or you can use the SUMPRODUCT function, which can perform that logic on your existing data with no need for helper columns. 或者,您可以使用SUMPRODUCT函数,该函数可以对现有数据执行该逻辑,而无需帮助程序列。

=SUMPRODUCT(LeaveTracker[Days]*(LeaveTracker[Employee Name]=valSelEmployee)*(WEEKDAY(LeaveTracker[Start Date])>5)*(WEEKDAY(LeaveTracker[End Date])>5)*(LeaveTracker[Type of Leave]='Leave Types'!B8))

The syntax for SUMIFS is : SUMIFS的语法为:

SUMIFS(sum_range, criteria_range1, criteria1, [criteria_range2, criteria2], ...)

If: 如果:

LeaveTracker[Days] is the sum_range and LeaveTracker [Days]是sum_range和

LeaveTracker[Employee Name] is the criteria_range LeaveTracker [员工姓名]是criteria_range

what is valSelEmployee? valSelEmployee是什么?

According to the syntax, it should be the first criteria. 根据语法,它应该是第一个标准。 Does it contain the Employee name to search? 它包含要搜索的员工姓名吗? If so, it should have an operator (=, > etc) 如果是这样,它应该有一个运算符(=,>等)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM