Generate an Excel lookup formula with Better Analyst
Describe what to look up in a table, then test the generated formula with a known match and a missing code.
What you will create
Ask Better Analyst for a formula that retrieves a quantity from a code, then check it against data with known results. Focus on specifying ranges, match type and what should happen when a code is missing.
Before you start
Use a practice worksheet rather than a live tracker. Prepare three fictional references and an empty result cell. Describing the cells is enough: there is no need to send a confidential workbook to the generator.
The example uses XLOOKUP, available in Excel Microsoft 365, 2021 and 2024, but not Excel 2016 or 2019. Specify your version, function language and argument separator. Check your Better Analyst access conditions rather than assuming every feature is free or unlimited.
Step-by-step
- Enter P-10, P-20 and P-30 in G2:G4. Enter 12, 0 and 27 respectively in H2:H4. Put the lookup code in A2 and reserve B2 for the result.
- Open Formula Generator in Better Analyst. Describe the references and request an exact match with a message for missing codes.
- Run Generate and read the formula before copying it. Use Explain if needed, but do not confuse an explanation with validation.
- Paste the formula into B2 and try the cases below. Do not overwrite existing data to make room.
- Copy the formula to a second test row and check that the reference table does not shift.
Example to adapt
Suggested prompt: “In English Excel Microsoft 365 using comma separators, look up A2 in G2:G4 and return H2:H4. Exact matches only. If missing, show Not found. Lock the reference table for copying downward. A recorded zero must remain zero.”
Reference formula to compare with the proposal, not a result claimed to have been generated by the tool:
=XLOOKUP(A2,$G$2:$G$4,$H$2:$H$4,"Not found",0)
P-10 should return 12, P-20 should return 0 and P-99 should display Not found. Zero is a known quantity; the message means the reference is absent. Confusing them would distort an inventory. Keep A2 populated in this exercise: define a separate rule for blank lookups if your application needs one.
Check your result
- Do the lookup and return ranges cover the same rows?
- Does a missing code produce the intended message rather than a nearby value?
- Does zero remain different from absence?
- When copied to B3, does A2 become A3 while the $ ranges stay fixed?
- Are codes unique? Returning the first match does not resolve duplicate data.
Common problems
Unknown function: check Excel version and localized names; request a compatible alternative if necessary. Rejected formula: check separators and quotation marks. A visible code is not found: compare spaces and data types in both columns. Misleading result: check that approximate matching was not introduced. A growing table: adjust ranges or adopt a structured table after verifying its references.
Next steps
Read the Better Analyst overview. Keep checking cases alongside the formula: they are more useful than a screenshot of a single correct result.



