AI basics & verificationPractical AI workflows

Audit an AI SUMIF formula when an asterisk is part of the actual code

The four teaching rows are A*=10, AB=20, A?=30 and A~=40. Matching all A-prefixed rows totals 100; matching the literal code A* totals 10. The formulas and incorrect draft below are editorial teaching material, not a recorded model or Excel session.

Hands typing on a laptop displaying a data table,illustrating conditional totals
Illustrative photo: Gorilla ROI Data Connector · Unsplash LicenseStock photograph; not a software screenshot,product test or announcement event.

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.

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.

A complete AI 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.
Original prompt, not an actual model call.

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.

Reproducible reference formulas
TaskFormulaExpected
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.

Further reading & sources