Smart Systems for Home

Plain how-to guides for smart home, security and home Wi-Fi

COUNTIFS in Excel: How to Count with Multiple Criteria

· 6 min read · Home Tech

In this article
  1. What You'll Need
  2. Step-by-Step
  3. Common Mistakes
  4. Tips
  5. Troubleshooting
  6. Frequently Asked Questions

The COUNTIFS function in Excel is used to count the number of cells across multiple ranges that meet a specific set of criteria. Unlike the standard COUNTIF function, which only allows for one condition, COUNTIFS allows you to apply multiple filters simultaneously. For example, you can use it to count how many sales were made by a specific employee in a specific month, or how many products in an inventory list are both "Out of Stock" and "Priority High." To use it, you simply pair a range of cells with a corresponding criterion, repeating this pair for every condition you want to track.

What You'll Need

  • A computer with Microsoft Excel installed (all modern versions support COUNTIFS).
  • A dataset organized in rows and columns (tables are recommended for better range management).
  • A clear understanding of the conditions you want to count (e.g., "Greater than 50" or "Exactly 'Completed'").

Step-by-Step

  1. Identify Your Criteria Ranges: Before typing the formula, determine which columns contain the data you need to filter. For instance, if you are counting orders that are "Shipped" and have a value over $100, your first range is the "Status" column and your second range is the "Order Value" column.
  2. Start the Formula: Click on the cell where you want the result to appear. Type =COUNTIFS(. This opens the function and prepares Excel to receive your range and criteria pairs.
  3. Enter the First Range: Select the first group of cells you want to evaluate. You can do this by clicking and dragging your mouse over the cells or by typing the range (e.g., A2:A100). Follow this immediately with a comma.
  4. Define the First Criterion: Enter the condition that the first range must meet.
    • If the criterion is text, wrap it in double quotes (e.g., "Shipped").
    • If the criterion is a number, you can enter it directly (e.g., 100).
    • If the criterion is a logical comparison, wrap it in quotes (e.g., ">100").
    • If the criterion is located in another cell, simply click that cell (e.g., B1).
    Add a comma after the criterion to move to the next pair.
  5. Enter Subsequent Range and Criteria Pairs: Repeat the process for every additional condition. For example, select the second column (e.g., B2:B100), add a comma, and then enter the second criterion (e.g., ">100"). You can add up to 127 pairs of ranges and criteria in a single formula.
  6. Close and Execute: Once all pairs are entered, type the closing parenthesis ) and press Enter. Excel will now return the total count of rows where all specified conditions are true.

Common Mistakes

One of the most frequent errors when writing a COUNTIFS formula is mismatched range sizes. Every range selected in the formula must have the exact same number of rows and columns. If your first range is A2:A100 (99 cells) and your second range is B2:B101 (100 cells), Excel will return a #VALUE! error. Always ensure your ranges start and end on the same row numbers.

Another common pitfall is the misuse of quotation marks. Users often forget that any text or logical operator (like <, >, or <>) must be enclosed in double quotes. For example, writing >50 instead of ">50" will cause the formula to fail. However, if you are referencing a cell that already contains the value 50, you must use an ampersand to join the operator and the cell reference, such as ">"&C1.

Users also frequently confuse the "AND" logic of COUNTIFS with "OR" logic. COUNTIFS only counts a row if every single condition is met. If you want to count rows that meet either Condition A or Condition B, you cannot do this with a single COUNTIFS function. Instead, you must write two separate COUNTIFS functions and add them together using the plus sign (e.g., =COUNTIFS(...) + COUNTIFS(...)).

Tips

To make your spreadsheets more dynamic, avoid hard-coding your criteria inside the formula. Instead, link the criteria to a specific cell. For example, instead of =COUNTIFS(A2:A100, "Completed"), use =COUNTIFS(A2:A100, D1). Now, whenever you change the text in cell D1, the count will update automatically without you having to edit the formula.

Utilize Wildcards for partial matches. If you need to count cells that start with a certain letter or contain a specific word, use the asterisk (*) symbol. For example, "North*" will count "North", "Northwest", and "Northeast". The question mark (?) can be used to replace a single character. This is incredibly useful for cleaning data where entries might have slight variations in spelling or formatting.

Convert your data into an official Excel Table (Ctrl + T). When you use Tables, you can use "Structured References" instead of cell ranges. Instead of A2:A100, your formula might look like =COUNTIFS(Table1[Status], "Shipped"). The benefit here is that as you add new rows to your table, the COUNTIFS formula updates automatically to include the new data, eliminating the need to manually update range references.

Troubleshooting

If your formula is returning 0 when you know there should be results, first check for leading or trailing spaces in your data. A cell that looks like it says "Shipped" but actually contains "Shipped " (with a space at the end) will not be counted by a criterion of "Shipped". You can fix this by using the TRIM function on your data or by using wildcards in your criteria, such as "*Shipped*".

If you see a #VALUE! error, double-check the dimensions of your ranges. As mentioned previously, if one range is longer than another, the formula will break. Ensure that all ranges start at the same row (e.g., row 2) and end at the same row (e.g., row 500).

If the formula is returning an unexpectedly high number, verify that your criteria are not too broad. For example, using "<>"&D1 counts everything that is not equal to the value in D1. If D1 is empty, you might be counting every single non-empty cell in the range.

If the formula simply doesn't calculate and shows the text of the formula instead, check the cell formatting. The cell may be formatted as "Text" instead of "General". Change the format to General, click into the formula bar, and press Enter to force Excel to recalculate.

Frequently Asked Questions

Can I use COUNTIFS to count unique values?

No, COUNTIFS is designed to count occurrences based on criteria, not to identify unique entries. To count unique values, you typically need to use a combination of the UNIQUE function and the COUNTA function, such as =COUNTA(UNIQUE(A2:A100)).

Is there a limit to how many criteria I can use?

Yes, Excel allows up to 127 range/criteria pairs in a single COUNTIFS function. While most users will never reach this limit, extremely complex datasets may require breaking the logic into multiple formulas.

Can I use dates as criteria in COUNTIFS?

Yes. You can enter dates in quotes (e.g., ">1/1/2023") or reference a cell containing a date. For better reliability across different regional date formats, it is recommended to use the DATE function within the formula, such as ">"&DATE(2023,1,1).

Does COUNTIFS work with blank cells?

Yes. To count cells that are blank, use "" as your criterion. To count cells that are not blank, use "<>". This is very helpful for tracking missing data in a large report.

What is the difference between COUNTIF and COUNTIFS?

COUNTIF only supports one range and one criterion. COUNTIFS supports multiple ranges and multiple criteria. Because COUNTIFS can do everything COUNTIF can do, many power users use COUNTIFS exclusively for all their counting needs to maintain consistency.