Key Takeaways
If a product code contains *, do not assume an asterisk in a SUMIF criterion is an ordinary character. Define literal versus pattern matching, escape the criterion where necessary and test the AI formula on rows that distinguish those meanings.
- Define literal codes versus patterns instead of letting AI guess the asterisk’s meaning.Read the supporting section: Define the code before asking AI for a formula
- For these rows, A~* selects literal A* and totals 10; the A* pattern totals 100.Read the supporting section: Three literal criteria and one pattern
- Verify distinguishing rows in the real workbook before changing the business formula.Read the supporting section: What remains to check in the actual workbook
In this article
Define the code before asking AI for a formula
Define A2:A5 as codes and B2:B5 as numeric quantities, with one independent record per row. The task is to sum records whose complete code equals A*. Here the asterisk belongs to the source identifier rather than meaning any suffix.
Microsoft’s SUMIF documentation explains criterion wildcards and the tilde escape for literal matching. A valid function name does not prove that the criterion expresses the intended task. State that distinction in the request.
A2:A5 contains A*, AB, A?, A~; B2:B5 contains 10, 20, 30, 40. Write an Excel formula summing only the complete literal code A*. Explain wildcard handling, give the result for these four rows and distinguish it from all codes starting with A.Why a plausible 100 can still be wrong
The teaching draft =SUMIF(A2:A5, "A*", B2:B5) uses an A-prefix pattern and has a reference total of 100 for these rows. It may solve a different task correctly while failing this literal-code task. Checking only for an error message would miss the problem.
With only A*=10, both pattern and literal criteria return 10, so the test cannot distinguish them. AB, A? and A~ provide counterexamples. Test rows should expose a wrong interpretation rather than merely produce a reassuring answer.
Three literal criteria and one pattern
For this case, use criterion "A~*" for literal A*, "A~?" for literal A? and "A~~" for literal A~. These are criterion-string forms, not instructions to rename source identifiers.
| Task | Formula | Expected |
|---|---|---|
| Literal A* | =SUMIF(A2:A5, "A~*", B2:B5) | 10 |
| Literal A? | =SUMIF(A2:A5, "A~?", B2:B5) | 30 |
| Literal A~ | =SUMIF(A2:A5, "A~~", B2:B5) | 40 |
| A-prefixed | =SUMIF(A2:A5, "A*", B2:B5) | 100 |
What remains to check in the actual workbook
Put the four rows in a blank workbook. Check equal range sizes and alignment, numeric quantities and the argument separators required by your Excel settings before running each reference formula. Retain the actual version and results. Inspect stray spaces or other characters before altering the business formula.
For neighboring issues, use the VLOOKUP missing-ID audit and AI formula sample-row method. Do not assume that every Excel function uses the same criterion syntax.
When criteria come from cells or external systems, define the input contract again and test escape order. This article supplies the fixed four-row case, not a universal formula covering every character, case rule or business-cleaning policy.
If another A* row has quantity 5, the literal-match reference total becomes 15, not 10 after silently deduplicating. SUMIF aggregates matching records. Whether business duplicates should be removed is a separate task requiring its own rule.


