Calculate a Weighted Margin in Excel with SUMIFS and Criteria
Question details
The user needs to calculate a weighted margin dynamically based on specific text criteria like region, country, or project using formulas.

- Product
- Excel
- Device & OS
- not provided
- Scenario
- Calculating weighted margins that dynamically update based on text criteria, including the use of wildcard characters for project names.
- Observed behavior
- The SUMPRODUCT function works for exact criteria matches but returns incorrect results when using an asterisk wildcard for project criteria.
Ensure your dataset includes dedicated columns for turnover (the weight), margin percentages, and your specific text criteria (such as region, country, and project name) before building the formula.
Use SUMIFS to Calculate the Weighted Margin
Calculate the weighted margin by dividing the sum of weighted margins by the total turnover, utilizing the SUMIFS function for both the numerator and denominator.
This approach is highly recommended when dealing with wildcards. SUMIFS handles asterisk (*) and question mark (?) wildcards natively, making it much more robust than SUMPRODUCT for partial text matches.
Insert a new column next to your data. In the first row, multiply the 'Turnover' cell by the 'Margin' cell to calculate the weighted value for that specific row, and drag the formula down.
Use a SUMIFS formula to sum the new helper column based on your desired criteria. For example: =SUMIFS(HelperColumn, RegionColumn, "North*").
Write a second SUMIFS formula to sum the 'Turnover' column using the exact same criteria.
Divide the numerator by the denominator into a single cell formula: =SUMIFS(HelperRange, CriteriaRange, "Criterion") / SUMIFS(TurnoverRange, CriteriaRange, "Criterion").

Adapt SUMPRODUCT to Handle Wildcards
If you prefer not to use a helper column, you can adapt the SUMPRODUCT function by forcing text conditions into TRUE/FALSE boolean arrays using search functions.
Calculate Complex Formulas Easily with WPS Spreadsheet
WPS Spreadsheet provides full support for advanced formulas like SUMIFS, SUMPRODUCT, and array operations, making it easy to calculate weighted margins and analyze complex financial data without compatibility issues.
- 1. Open your dataset: Launch WPS Spreadsheet and open the workbook containing your turnover and margin data.
- 2. Enter the SUMIFS formula: Select an empty cell and input your structured =SUMIFS()/SUMIFS() formula to calculate the weighted margin.
- 3. Apply wildcards dynamically: Type your text criteria, using asterisks (*) for partial matches if needed, and press Enter to instantly view the precise weighted result.

Frequently Asked Questions
Why doesn't SUMPRODUCT work directly with asterisk wildcards?
SUMPRODUCT evaluates arrays using exact mathematical and logical matches. An asterisk is treated as a literal character rather than a wildcard unless combined with specific text-search functions like SEARCH or FIND.
Can I use AVERAGEIF to calculate a weighted margin?
No. The AVERAGEIF function only calculates a simple, unweighted average based on your criteria. It does not account for the varying weights (like total turnover volume) associated with each margin percentage.
Do I always need a helper column when using SUMIFS for weighted averages?
Yes, SUMIFS requires an existing physical range of cells to sum. Therefore, you must create a helper column that multiplies the weight by the value (e.g., Turnover * Margin) before using the SUMIFS function on that new range.




