Excel 是用于数据收集和输入的绝佳工具,如今它在全球范围内被广泛使用。为了简化数据管理任务,Excel 具有一些内置函数和公式。 SUMIF就是这样一个函数。此函数可以轻松地对大型数据集中的特定数字求和。这基本上是一个工作表函数,属于Math & Trigonometry函数。
这个函数完全符合它的名字所指示的功能。使用此函数,我们可以获得满足给定条件的特定范围“IF”的数字的“SUM” 。该函数实际上评估应用条件的特定范围的总和。在这个函数,我们可以对一个范围应用标准,并根据标准总结另一个范围。
Syntax:
SUMIF(range, criteria, [sum_range](optional))
***[sum_range] is an optional argument.
此函数接受范围、条件(条件)和 sum_range(可选参数)作为其参数,并根据给定的参数返回 sum_range 或范围的总和。下面讨论这些论点。
Arguments:
Arguments of the SUMIF function are the following:
- range(Required): This is the range of the cells that will be evaluated to check the given criteria or condition. These cells may contain numbers or names, dates(must be in standard excel formats), arrays, references(that contains numbers).
- criteria(Required): This argument is the criteria that need to be satisfied to add a cell of the given range. It can be a number, expression(logical or mathematical), text, reference, or a function. If the criteria is a mathematical or logical expression it must be written within double quote(Eg: ” >1000″). On the other hand, if the criteria is a number then the double quote is not required(Eg: 56). There are some special symbols like a question mark(‘?’) And asterisk(‘*’) with some special use:
- A question mark(?) can be used to match a single character.
- An asterisk(*) can be used to match a sequence of characters.
- And if we want to match a question mark(?) or an asterisk in the cell we need to use a tilde sign before them(Eg: “~?”).
- sum_range(Optional): This is the actual range that will be added cell by cell if the given criteria meet. But if this argument is not provided then the SUMIF function will return the sum of the range argument. sum_range should be of the same dimension of range argument for better performance.
Return Value:
This function sums the numbers in the given range and returns the numerical value of the sum.
例子:
以 Excel 工作表为例,SUMIF函数已用于多种格式。
Coding Team names(Column A) | No. of members(Column B) | points(Column C) |
---|---|---|
GFG_CODERS | 4 | 200 |
Acex_coders | 5 | 197 |
Poisionous_python | 3 | 150 |
Megatron | 4 | 130 |
Bro_coders | 6 | 110 |
Kotlin_coders | 2 | 100 |
Gaming_coders | 3 | 50 |
然后我们将SUMIF()函数应用于上表:
SUMIF() function | What the function does | Output result |
---|---|---|
=SUMIF(B2:B8, “>4”, C2:C8) | If the no. of members in column B is greater than 4 then add the corresponding points of column C. | 307 |
=SUMIF(B2:B8, 4, C2:C8) | If the no. of members in column B is equal to 4 then add the corresponding points of column C. | 330 |
=SUMIF(A2:A8, “GFG_CODERS”, C2:C8) | Search for “GFG_CODERS” in column A and add the corresponding points in column C. | 200 |
=SUMIF(C2:C8, “>110”) | Here the sum_range argument is not provided. So it will check the cells of C column and if the points are greater than 110 add it to the result. | 677 |
=SUMIF(A2:A8, “*rs”, C2:C8) | Here it will find the names of the teams ending with “rs” / “RS” in column A and add the corresponding points to the sum. | 657 |
输出: