Function Problems

How to Average Cells That Meet One of Two Conditions in Excel

Khadija KhanKhadija Khan Oct 8, 2026 869 views

Question details

Calculate the average of values that meet at least one of two specific criteria, including scenarios where cells are highlighted by conditional formatting.

How to Average Cells That Meet One of Two Conditions in Excel
Product
Microsoft Excel
Device & OS
not provided
Scenario
Performing mathematical averages on datasets where data needs to be filtered by multiple OR conditions rather than strict AND conditions.
Observed behavior
The user wants to find the average using logical OR conditions but realizes that conditional formatting colors only change appearance and cannot be used directly as a calculation condition.
Before you start

Identify the exact mathematical or logical rules used in your conditional formatting, as Excel formula functions rely on underlying cell values rather than applied cell colors.

Solution 1Recommended

Use SUMIF and COUNTIF for OR Conditions

Since AVERAGEIFS applies strict AND logic, using a combination of SUMIF and COUNTIF allows you to average cells meeting one of two conditions (OR logic).

If you want to average cells where the value is either one condition or another, AVERAGEIFS will not work because it requires all conditions to be true simultaneously. Instead, calculating the total sum of those items and dividing it by their total count provides an accurate average.

1
Select a target cell

Click on an empty cell where you want to output the calculated average.

2
Enter the formula combination

Type the formula: =SUM(SUMIF(A2:A10, {"Condition1","Condition2"}, B2:B10)) / SUM(COUNTIF(A2:A10, {"Condition1","Condition2"})).

3
Customize the formula

Replace A2:A10 with your criteria range, B2:B10 with your values range, and replace the conditions with your actual text or numbers.

4
Calculate the result

Press Enter to calculate the average of the cells that meet either condition.

Use SUMIF and COUNTIF for OR Conditions
Avoid Double Counting: If your two conditions can overlap on the exact same cell, this formula might count that cell twice. Use a SUMPRODUCT formula for overlapping OR conditions instead.

Calculate Complex Averages Easily in WPS Spreadsheet

WPS Spreadsheet fully supports advanced logical formulas, array calculations, and statistical functions like AVERAGEIF and SUMPRODUCT. You can seamlessly process multiple conditions and replicate complex Excel workflows with zero learning curve.

  1. 1. Open your workbook: Launch WPS Spreadsheet and open the document containing your data.
  2. 2. Navigate to Formulas: Select the target cell, then go to the 'Formulas' tab on the top ribbon.
  3. 3. Insert Function: Click 'Insert Function' and search for SUMIF or AVERAGEIF.
  4. 4. Configure Criteria: Follow the intuitive dialog box to input your ranges and multiple conditions, then click 'OK' to generate your exact average.
100% compatible with Microsoft Excel formulas and functionsBuilt-in formula error-checking and evaluation toolsLightweight application with high-speed processing for large datasetsFree to use for daily spreadsheet analysis and reporting
microsoft office alternative - wps office

Frequently Asked Questions

Can I average cells based strictly on their background color?

Spreadsheet formulas cannot natively calculate averages based on conditional formatting colors. You must either use the mathematical rule that triggered the color inside an AVERAGEIF function, or use VBA macros to sum by the color property.

Why does AVERAGEIFS return 0 or a #DIV/0! error when I use two conditions for the same column?

The AVERAGEIFS function uses strict AND logic. If you apply two mutually exclusive conditions to the same column (e.g., equal to 'Apple' and equal to 'Orange'), it looks for a cell that is simultaneously both, which is impossible, resulting in zero matching cells.

How do I average cells while ignoring zeroes?

You can use the AVERAGEIF or AVERAGEIFS function to exclude zeroes by setting the criteria to "<>0". For example: =AVERAGEIF(B2:B10, "<>0").

Is there an easier way to average with OR logic in newer versions?

Yes, if you have access to modern dynamic arrays, you can use the FILTER function wrapped in an AVERAGE function: =AVERAGE(FILTER(B2:B10, (A2:A10="Condition1")+(A2:A10="Condition2"))). The plus sign acts as the OR operator.