How to Calculate Average Based on Multiple Criteria in Excel
Question details
The user needs to calculate the average percentage for specific Grouping IDs and display the result conditionally only on rows containing a specific marker.

- Product
- Excel
- Device & OS
- not provided
- Scenario
- Calculating conditional averages based on grouping identifiers and displaying the results only on designated rows while leaving other rows blank.
- Observed behavior
- Requires a combined formula to conditionally evaluate data across ranges and output the calculated average only when a row-level condition is met.
Ensure your data is organized in clear columns (e.g., Grouping ID, Marker, Percentage) and that there are no merged cells within your data range, as this can cause formula calculation errors.
Use IF and AVERAGEIFS Functions Together
Combine the IF function to check for the row marker and AVERAGEIFS to calculate the average for the specific Grouping ID.
To achieve this, you need to nest an AVERAGEIFS function inside an IF function. The IF function will first check if the current row contains your required marker (e.g., 'H'). If it does, the AVERAGEIFS function will calculate the average of the specified values matching the Grouping ID. If it does not, the IF function will return a blank cell.
Click on the cell where you want the first result to appear, such as cell E2.
Type the formula =IF(B2="H",AVERAGEIFS($D$2:$D$10000,$A$2:$A$10000,A2),""). Make sure to adjust the absolute ranges ($D$2:$D$10000 for the values to average, $A$2:$A$10000 for the Grouping IDs) and relative references (B2 for the row marker, A2 for the current Grouping ID) to match your actual dataset.
Press Enter to apply the formula to the first cell. Then, click and drag the fill handle (the small square at the bottom-right corner of the cell) down the column to apply it to all other rows.

Easily Handle Complex Formulas in WPS Office
WPS Spreadsheet offers comprehensive support for advanced statistical and logical functions, allowing you to seamlessly calculate conditional averages and manage complex data.
- 1. Open your dataset: Launch WPS Spreadsheet and open your workbook containing the grouping IDs and percentages.
- 2. Insert the function: Select the output cell, go to the 'Formulas' tab, and click 'Insert Function' to build your formula, or directly type =IF(B2="H",AVERAGEIFS($D$2:$D$10000,$A$2:$A$10000,A2),"").
- 3. Fill the data: Press Enter and double-click the fill handle to automatically populate the conditional averages down the entire column.

Frequently Asked Questions
Why does my AVERAGEIFS formula return a #DIV/0! error?
This error occurs when there are no cells that meet all the specified criteria in your AVERAGEIFS function, causing Excel to attempt to divide by zero. Ensure your criteria ranges contain data that exactly matches your specified conditions.
Can I use AVERAGEIF instead of AVERAGEIFS for multiple criteria?
No, AVERAGEIF is designed to evaluate only a single condition. If you need to evaluate multiple conditions or criteria across different columns, you must use the AVERAGEIFS function.
How do I lock the cell references in my formula?
You can lock cell references by making them absolute using dollar signs (e.g., $A$2:$A$10000). To do this quickly, select the cell reference in the formula bar and press the F4 key on your keyboard.
Why is my IF formula displaying a zero instead of remaining blank?
To leave a cell blank when the IF condition evaluates to false, you must explicitly use empty double quotes ("") as the value_if_false argument in your IF statement. If you omit this, the formula defaults to returning 0 or FALSE.




