На чтение 2 мин
Функция СУММЕСЛИ (SUMIF) в Excel используется для суммирования значений, отвечающих заданным вами критериям.
Содержание
- Что возвращает функция
- Синтаксис
- Аргументы функции
- Дополнительная информация
- Примеры использования функции СУММЕСЛИ в Excel
Что возвращает функция
Возвращает сумму чисел, указанных в качестве аргументов и отвечающих заданным в формуле критериям.
Больше лайфхаков в нашем Telegram Подписаться
Синтаксис
=SUMIF(range, criteria [sum_range]) — английская версия
=СУММЕСЛИ(диапазон; условие; [диапазон_суммирования]) — русская версия
Аргументы функции
- range (диапазон) — диапазон ячеек, по которым оцениваются критерии. Аргументом могут быть числа, текст, массивы или ссылки, содержащие числа;
- criteria (условие) — критерии, которые проверяются по указанному диапазону ячеек и определяют, какие ячейки суммировать;
- sum_range (диапазон_суммирования) — (не обязательно) суммируемые ячейки. Если этот аргумент не указан, то функция использует аргумент range (диапазон) в качестве sum_range (диапазон_суммирования).
Дополнительная информация
- суммирование ячеек в функции СУММЕСЛИ производится на основе одного критерия, если вам необходимо указать несколько критериев — используйте функцию SUMIFS (СУММЕСЛИМН);
- пустые и текстовые ячейки в аргументе sum_range (диапазон_суммирования) игнорируются;
- критерием для функции могут служить числа, выражения, результаты вычисления из других ячеек, текст или формула;
- если в качестве критерия указан текст или математический/логический символ (=,+,-,/,*), то такие значения должны быть указаны в двойных кавычках;
- аргумент с критерием не должен быть длиннее чем 255 символов;
- в качестве критерия могут использоваться подстановочные знаки (*);
- если количество ячеек в диапазоне критерия и аргументе sum_range (диапазон_суммирования) различаются, то размер диапазона критерия будет в приоритете.
Примеры использования функции СУММЕСЛИ в Excel
You use the SUMIF function to sum the values in a range that meet criteria that you specify. For example, suppose that in a column that contains numbers, you want to sum only the values that are larger than 5. You can use the following formula: =SUMIF(B2:B25,»>5″)
This video is part of a training course called Add numbers in Excel.
Tips:
-
If you want, you can apply the criteria to one range and sum the corresponding values in a different range. For example, the formula =SUMIF(B2:B5, «John», C2:C5) sums only the values in the range C2:C5, where the corresponding cells in the range B2:B5 equal «John.»
-
To sum cells based on multiple criteria, see SUMIFS function.
Important: The SUMIF function returns incorrect results when you use it to match strings longer than 255 characters or to the string #VALUE!.
Syntax
SUMIF(range, criteria, [sum_range])
The SUMIF function syntax has the following arguments:
-
range Required. The range of cells that you want evaluated by criteria. Cells in each range must be numbers or names, arrays, or references that contain numbers. Blank and text values are ignored. The selected range may contain dates in standard Excel format (examples below).
-
criteria Required. The criteria in the form of a number, expression, a cell reference, text, or a function that defines which cells will be added. Wildcard characters can be included — a question mark (?) to match any single character, an asterisk (*) to match any sequence of characters. If you want to find an actual question mark or asterisk, type a tilde (~) preceding the character.
For example, criteria can be expressed as 32, «>32», B5, «3?», «apple*», «*~?», or TODAY().
Important: Any text criteria or any criteria that includes logical or mathematical symbols must be enclosed in double quotation marks («). If the criteria is numeric, double quotation marks are not required.
-
sum_range Optional. The actual cells to add, if you want to add cells other than those specified in the range argument. If the sum_range argument is omitted, Excel adds the cells that are specified in the range argument (the same cells to which the criteria is applied).
Sum_range
should be the same size and shape as range. If it isn’t, performance may suffer, and the formula will sum a range of cells that starts with the first cell in sum_range but has the same dimensions as range. For example:
range
sum_range
Actual summed cells
A1:A5
B1:B5
B1:B5
A1:A5
B1:K5
B1:B5
Examples
Example 1
Copy the example data in the following table, and paste it in cell A1 of a new Excel worksheet. For formulas to show results, select them, press F2, and then press Enter. If you need to, you can adjust the column widths to see all the data.
Property Value |
Commission |
Data |
---|---|---|
$100,000 |
$7,000 |
$250,000 |
$200,000 |
$14,000 |
|
$300,000 |
$21,000 |
|
$400,000 |
$28,000 |
|
Formula |
Description |
Result |
=SUMIF(A2:A5,»>160000″,B2:B5) |
Sum of the commissions for property values over $160,000. |
$63,000 |
=SUMIF(A2:A5,»>160000″) |
Sum of the property values over $160,000. |
$900,000 |
=SUMIF(A2:A5,300000,B2:B5) |
Sum of the commissions for property values equal to $300,000. |
$21,000 |
=SUMIF(A2:A5,»>» & C2,B2:B5) |
Sum of the commissions for property values greater than the value in C2. |
$49,000 |
Example 2
Copy the example data in the following table, and paste it in cell A1 of a new Excel worksheet. For formulas to show results, select them, press F2, and then press Enter. If you need to, you can adjust the column widths to see all the data.
Category |
Food |
Sales |
---|---|---|
Vegetables |
Tomatoes |
$2,300 |
Vegetables |
Celery |
$5,500 |
Fruits |
Oranges |
$800 |
Butter |
$400 |
|
Vegetables |
Carrots |
$4,200 |
Fruits |
Apples |
$1,200 |
Formula |
Description |
Result |
=SUMIF(A2:A7,»Fruits»,C2:C7) |
Sum of the sales of all foods in the «Fruits» category. |
$2,000 |
=SUMIF(A2:A7,»Vegetables»,C2:C7) |
Sum of the sales of all foods in the «Vegetables» category. |
$12,000 |
=SUMIF(B2:B7,»*es»,C2:C7) |
Sum of the sales of all foods that end in «es» (Tomatoes, Oranges, and Apples). |
$4,300 |
=SUMIF(A2:A7,»»,C2:C7) |
Sum of the sales of all foods that do not have a category specified. |
$400 |
Top of Page
Need more help?
See also
SUMIFS function
COUNTIF function
Sum values based on multiple conditions
How to avoid broken formulas
VLOOKUP function
При работе с листами Excel вам может потребоваться суммировать значения на основе нескольких критериев. Иногда несколько критериев взяты из одного столбца (логика ИЛИ), но иногда из разных столбцов (логика И). В таком случае, как бы вы могли справиться с этой задачей в Excel?
- Sumif с несколькими критериями на основе логики ИЛИ
- Используя формулу СУММЕСЛИ + СУММЕСЛИ +…
- Используя функции СУММ и СУММЕСЛИ
- Sumif с несколькими критериями на основе логики И с использованием функции СУММЕСЛИМН
Sumif с несколькими критериями на основе логики ИЛИ
Предположим, у вас есть список продуктов, который содержит поставщика и количество, как показано на скриншоте ниже, теперь вы хотите получить все общие количества, которые поставляются поставщиком Джоном и Дэвидом. Здесь я представлю вам две простые формулы.
Используя формулу СУММЕСЛИ + СУММЕСЛИ +…
Если вы хотите суммировать числа, которые соответствуют любому из критериев (логика ИЛИ) из нескольких критериев, вы можете сложить несколько функций СУММЕСЛИ в одной формуле, общий синтаксис следующий:
=SUMIF(criteria_range, criteria1, sum_range)+SUMIF(criteria_range, criteria2, sum_range)+…
- criteria_range: Диапазон ячеек, который должен соответствовать критериям;
- criteria1: Первый критерий, используемый для определения суммирования ячеек;
- criteria2: Второй критерий, используемый для определения суммирования ячеек;
- sum_range: Диапазон ячеек, по которым вы хотите произвести суммирование.
Теперь скопируйте или введите любую из приведенных ниже формул в пустую ячейку и нажмите Enter ключ для получения результата:
=SUMIF(B4:B14,«John»,C4:C14) + SUMIF(B4:B14,«David»,C4:C14) (Type the criteria manually)
=SUMIF(B4:B14,E4,C4:C14) + SUMIF(B4:B14,E5,C4:C14) (Use a cell reference)
Пояснение к формуле:
=SUMIF(B4:B14,»John»,C4:C14) + SUMIF(B4:B14,»David»,C4:C14)
- Первый СУММЕСЛИ (B4: B14; «Джон»; C4: C14) находит строки Джона и суммирует общие количества;
- Второй СУММЕСЛИ (B4: B14, «Давид», C4: C14) находит строки Давида и суммирует общие количества;
- Затем сложите эти две формулы СУММЕСЛИ, чтобы получить все общие количества, предоставленные Джоном и Дэвидом.
Используя функции СУММ и СУММЕСЛИ
Приведенная выше формула очень проста в использовании, если есть только пара критериев, но если вы хотите суммировать значения с несколькими условиями ИЛИ, приведенная выше формула может быть избыточной. В этом случае лучшая формула, созданная на основе функций СУММ и СУММЕСЛИ, может оказать вам услугу. Общие синтаксисы:
Общая формула с жестко закодированным текстом:
=SUM(SUMIF(criteria_range, {criteria1,criteria2,…}, sum_range))
- criteria_range: Диапазон ячеек, который должен соответствовать критериям;
- criteria1: Первый критерий, используемый для определения суммирования ячеек;
- criteria2: Второй критерий, используемый для определения суммирования ячеек;
- sum_range: Диапазон ячеек, по которым вы хотите произвести суммирование.
Общая формула со ссылками на ячейки:
{=SUM(SUMIF(criteria_range, criteria_cells, sum_range))}
Array formula, should press Ctrl + Shift + Enter keys together.
- criteria_range: Диапазон ячеек, который должен соответствовать критериям;
- criteria_cells: Ячейки, содержащие критерии, которые вы хотите использовать;
- sum_range: Диапазон ячеек, по которым вы хотите произвести суммирование.
Пожалуйста, введите или скопируйте любую из приведенных ниже формул в пустую ячейку и получите результат:
=SUM(SUMIF(B4:B14, {«John»,»David»}, C4:C14)) (Type the criteria manually)
=SUM(SUMIF(B4:B14, E4:E5, C4:C14)) (Use cell references, array formula, should press Ctrl + Shift + Enter keys)
Пояснение к формуле:
= СУММ (СУММЕСЛИ (B4: B14; {«Джон»; «Давид»}; C4: C14))
> СУММЕСЛИ (B4: B14, {«Джон», «Давид»}, C4: C14):
- {«Джон», «Дэвид»}: Константа массива, которая представляет собой набор нескольких критериев, заключенных в фигурные скобки.
- СУММЕСЛИ (B4: B14, «Давид», C4: C14) Константа массива, использующая логику ИЛИ, заставляет функцию СУММЕСЛИ суммировать числа в C4: C14 на основе любого из нескольких критериев («Джон» и «Дэвид»), и она возвращает два отдельных результата: {410,1520}.
> СУММ (СУММЕСЛИ (B4: B14, {«Джон», «Давид»}, C4: C14)) = СУММ ({410,1520}): Наконец, эта функция SUM складывает эти результаты массива, чтобы вернуть результат: 1930.
Sumif с несколькими критериями на основе логики И с использованием функции СУММЕСЛИМН
Если вы хотите суммировать значения с несколькими критериями в разных столбцах, вы можете использовать функцию СУММЕСЛИ, чтобы быстро решить эту задачу. Общий синтаксис:
=SUMIFS(sum_range, criteria_range1, criteria1, [criteria_range2, criteria2], …)
- sum_range: Диапазон ячеек, по которым вы хотите произвести суммирование;
- criteria_range1: Диапазон, в котором применяется критерий1;
- criteria1: Первый критерий, который проверяется по диапазону критериев1 и определяет, какие ячейки нужно добавить; (типом критерия может быть: число, логическое выражение, ссылка на ячейку, текст, дата или другая функция Excel.)
- criteria_range2, criteria2…: Другие дополнительные диапазоны и связанные с ними критерии. (вы можете установить 127 пар критериев_диапазона и критериев в формуле СУММЕСЛИМН.)
Скажем, у меня есть таблица со столбцами Product, Supplier, Qty и Price, как показано на скриншоте ниже. Теперь я хочу узнать сумму общей цены продукта Apple и количества, которое больше или равно 200.
Примените любую из приведенных ниже формул в пустую ячейку и нажмите Enter ключ для возврата результата:
=SUMIFS(D4:D14,A4:A14,«Apple»,C4:C14,«>=200») (Type the criteria manually)
=SUMIFS(C4:C14,A4:A14,G3,C4:C14,G4) (Use cell references)
Пояснение к формуле:
=SUMIFS(D4:D14,A4:A14,»Apple»,C4:C14,»>=200″)
- Диапазон A4: A14 проверяет наличие продукта «Apple», а диапазон C4: C14 извлекает все количества, превышающие или равные 200, затем функция СУММЕСЛИМН суммирует только совпавшие ячейки из диапазона D4: D14.
Используемая относительная функция:
- SUMIF:
- Функция СУММЕСЛИ может помочь суммировать ячейки на основе одного критерия.
- SUMIFS:
- Функция СУММЕСЛИМН в Excel может помочь суммировать значения ячеек на основе нескольких критериев.
Другие статьи:
- Сумма, если начинается или заканчивается конкретным текстом или символами
- Чтобы суммировать значения, если соответствующие ячейки начинаются или заканчиваются определенным значением, вы можете применить функцию СУММЕСЛИ с подстановочным знаком (*), чтобы получить ее. В этой статье мы подробно расскажем, как пользоваться формулой.
- Сумма, если ячейки содержат определенный текст в другом столбце
- Из этого туториала Вы узнаете, как суммировать значения, если ячейки содержат определенный или частичный текст в другом столбце. В качестве примера возьмем диапазон данных ниже, чтобы получить общее количество продуктов, содержащих текст «Футболка», с этой задачей в Excel могут справиться как функция СУММЕСЛИ, так и функция СУММПРОИЗВ.
- Сумма наименьших или нижних значений N в Excel
- В Excel легко суммировать диапазон ячеек с помощью функции СУММ. Иногда вам может потребоваться суммировать наименьшие или нижние 3, 5 или n чисел в диапазоне данных, как показано ниже. В этом случае СУММПРОИЗВ вместе с функцией МАЛЕНЬКИЙ могут помочь вам решить эту проблему в Excel.
Лучшие инструменты для работы в офисе
Kutools for Excel — Помогает вам выделиться из толпы
Хотите быстро и качественно выполнять свою повседневную работу? Kutools for Excel предлагает 300 мощных расширенных функций (объединение книг, суммирование по цвету, разделение содержимого ячеек, преобразование даты и т. д.) и экономит для вас 80 % времени.
- Разработан для 1500 рабочих сценариев, помогает решить 80% проблем с Excel.
- Уменьшите количество нажатий на клавиатуру и мышь каждый день, избавьтесь от усталости глаз и рук.
- Станьте экспертом по Excel за 3 минуты. Больше не нужно запоминать какие-либо болезненные формулы и коды VBA.
- 30-дневная неограниченная бесплатная пробная версия. 60-дневная гарантия возврата денег. Бесплатное обновление и поддержка 2 года.
Вкладка Office — включение чтения и редактирования с вкладками в Microsoft Office (включая Excel)
- Одна секунда для переключения между десятками открытых документов!
- Уменьшите количество щелчков мышью на сотни каждый день, попрощайтесь с рукой мыши.
- Повышает вашу продуктивность на 50% при просмотре и редактировании нескольких документов.
- Добавляет эффективные вкладки в Office (включая Excel), точно так же, как Chrome, Firefox и новый Internet Explorer.
What to Know
- Enter input data > use «= SUMIFS (Sum_range,Criteria_range1,Criteria1, …)» syntax.
- Starting function: Select desired cell > select Formulas tab > Math & Trig > SUMIFS.
- Or: Select desired cell > select Insert Function > Math & Trig > SUMIFS to start function.
This article explains how to use the SUMIFS function in Excel 2019, 2016, 2013, 2010, Excel for Microsoft 365, Excel 2019 for Mac, Excel 2016 for Mac, Excel for Mac 2011, and Excel Online.
Entering the Tutorial Data
The first step to using the SUMIFS function in Excel is to input the data.
Enter the data into cells D1 to F11 of an Excel worksheet, as seen in the image above.
The SUMIFS function and the search criteria (less than 275 orders and sales agents from the East sales region) goes in row 12 below the data.
The tutorial instructions do not include formatting steps for the worksheet. While formatting will not interfere with completing the tutorial, your worksheet will look different than the example shown. The SUMIFS function will give you the same results.
The SUMIFS Function’s Syntax
In Excel, a function’s syntax refers to the layout of the function and includes the function’s name, brackets, and arguments.
The syntax for the SUMIFS function is:
= SUMIFS (Sum_range,Criteria_range1,Criteria1,Criteria_range2,Criteria2, ...)
Up to 127 Criteria_range / Criteria pairs can be specified in the function.
Starting the SUMIFS Function
Although it is possible to just the SUMIFS function directly into a cell in a worksheet, many people find it easier to use the function’s dialog box to enter the function.
- Click cell F12 to make it the active cell; F12 is where you will enter the SUMIFS function.
- Click the Formulas tab.
- Click Math & Trig in the Function Library group.
- Click SUMIFS in the list to bring up the SUMIFS function’s dialog box.
Excel Online does not have the Formulas tab. To use SUMIFS in Excel Online, go to Insert > Function.
- Click cell F12 to make it the active cell so you can enter the SUMIFS function.
- Click the Insert Function button. The Insert Function dialog box opens.
- Click Math & Trig in the Categories list.
- Click SUMIFS in the list to start the function.
The data that we enter into the blank lines in the dialog box will form the arguments of the SUMIFS function.
These arguments tell the function what conditions we are testing for and what range of data to sum when it meets those conditions.
Entering the Sum_range Argument
The Sum_range argument contains the cell references to the data we want to add up.
In this tutorial, the data for the Sum_range argument goes in the Total Sales column.
Tutorial Steps
- Click the Sum_range line in the dialog box.
- Highlight cells F3 to F9 in the worksheet to add these cell references to the Sum_range line.
Entering the Criteria_range1 Argument
In this tutorial we are trying to match two criteria in each data record:
- Sales agents from the East sales region
- Sales agents who have made fewer than 275 sales this year
The Criteria_range1 argument indicates the range of cells the SUMIFS is to search when trying to match the first criteria: the East sales region.
Tutorial Steps
- Click the Criteria_range1 line in the dialog box.
- Highlight cells D3 to D9 in the worksheet to enter these cell references as the range to be searched by the function.
Entering the Criteria1 Argument
The first criteria we are looking to match is if data in the range D3:D9 equals East.
Although actual data, such as the word East, can be entered into the dialog box for this argument it is usually best to add the data to a cell in the worksheet and then input that cell reference into the dialog box.
Tutorial Steps
- Click the Criteria1 line in the dialog box.
- Click cell D12 to enter that cell reference. The function will search the range selected in the previous step for data that matches these criteria.
How Cell References Increase SUMIFS Versatility
If a cell reference, such as D12, is entered as the Criteria Argument, the SUMIFS function will look for matches to whatever data is in that cell in the worksheet.
So after finding the sales amount for the East region, it will be easy to locate the same data for another sales region simply by changing East to North or West in cell D12. The function will automatically update and display the new result.
Entering the Criteria_range2 Argument
The Criteria_range2 argument indicates the range of cells the SUMIFS is to search when trying to match the second criteria: sales agents who have sold fewer than 275 orders this year.
- Click the Criteria_range2 line in the dialog box.
- Highlight cells E3 to E9 in the worksheet to enter these cell references as the second range to be searched by the function.
Entering the Criteria2 Argument
The second standard we are looking to match is if data in the range E3:E9 is less than 275 sales orders.
As with the Criteria1 argument, we will enter the cell reference to Criteria2’s location into the dialog box rather than the data itself.
- Click the Criteria2 line in the dialog box.
- Click cell E12 to enter that cell reference. The function will search the range selected in the previous step for data that matches the criteria.
- Click OK to complete the SUMIFS function and close the dialog box.
An answer of zero (0) will appear in cell F12 (the cell where we entered the function) because we have not yet added the data to the Criteria1 and Criteria2 fields (C12 and D12). Until we do, there is nothing for the function to add up, and so the total stays at zero.
Adding the Search Criteria and Completing the Tutorial
The last step in the tutorial is to add data to the cells in the worksheet identified as containing the Criteria arguments.
For help with this example see the image above.
- In cell D12 type East and press the Enter key on the keyboard.
- In cell E12 type <275 and press the Enter key on the keyboard (the » < » is the symbol for less than in Excel).
The answer $119,719.00 should appear in cell F12.
Only two records, those in rows 3 and 4 match both criteria and, therefore, only the sales totals for those two records are summed by the function.
The sum of $49,017 and $70,702 is $119,719.
When you click on cell F12, the complete function =SUMIFS(F3:F9,D3:D9,D12,E3:E9,E12) appears in the formula bar above the worksheet.
How the SUMIFS Function Works
Usually, SUMIFS works with rows of data called records. In a record, all of the data in each cell or field in the row is related, such as a company’s name, address and phone number.
The SUMIFS argument looks for specific criteria in two or more fields in the record and only if it finds a match for each field specified is the data for that record summed up.
In the SUMIF step by step tutorial, we matched the single criterion of sales agents who had sold more than 250 orders in a year.
In this tutorial, we will set two conditions using SUMIFS: that of sales agents in the East sales region who had fewer than 275 sales in the past year.
Setting more than two conditions can be done by specifying additional Criteria_range and Criteria arguments for SUMIFS.
The SUMIFS Function’s Arguments
The function’s arguments tell it which conditions to test for and what range of data to sum when it meets those conditions.
All arguments in this function are required.
Sum_range — the data in this range of cells is summed when a match is found between all specified Criteria and their corresponding Criteria_range arguments.
Criteria_range — the group of cells the function is to search for a match to the corresponding Criteria argument.
Criteria — this value is compared with the data in the corresponding.
Criteria_range — actual data or the cell reference to the data for the argument.
Thanks for letting us know!
Get the Latest Tech News Delivered Every Day
Subscribe