Getting started

Writing categorisation rules that survive messy bank narrations

How to write categorisation rules for messy bank narrations: pick the stable merchant name, ignore reference numbers, and judge how broad a rule can safely be.

Editorial illustration for Writing categorisation rules that survive messy bank narrations

A categorisation rule that survives messy narrations is built on the one part of the text that never changes, the merchant name, and ignores everything that does, such as reference numbers, dates, card digits and branch codes. Keep it short enough to match every spelling you see, and specific enough that it does not catch a different shop.

What part of a narration should a rule look at?

A narration has a stable part and a changing part. Write the rule on the stable one.

  • Stable: the merchant or payee name, and sometimes a distinctive word in it.
  • Changing: UPI reference numbers, transaction IDs, dates, times, masked card numbers, terminal IDs, city or branch codes.
  • Sometimes stable, sometimes not: payment-app suffixes at the end of a UPI string, which depend on how you paid.

Three worked examples

These narrations are invented, to show the thinking. Your own statement will look different.

Noisy narrationStable partRule text, and category
UPI/918273645012/HILLSIDE COFFEE/okicici/PaymentHILLSIDEContains HILLSIDE, Eating out
POS 4871XXXXXXXX0022 SHREE FUELS PUNE 02NOVSHREE FUELSContains SHREE FUELS, Fuel
IMPS/P2A/530011223344/GREEN VALLEY RWA/MAINTGREEN VALLEYContains GREEN VALLEY, Society maintenance

In the first, the long number changes on every payment, so putting it in the rule would make it match once and never again. In the second, the card digits and the date are noise, and a city may or may not be there next time. In the third, the word MAINT may also appear in a different month's narration as MAINTENANCE, so it is safer to rely on the society's name alone.

How broad is too broad?

Test the rule against your last three months of rows before you trust it. Imagine a rule on the single word PETROL. It will catch fuel, but also a petrol-pump snack shop or a fuel-card top-up you want elsewhere. A rule on a short common word such as SHOP or STORE will catch half your statement. On the other hand, a rule on the full merchant string with a store number in it is so narrow it will fail next time.

  1. Pick the shortest piece of text that still identifies one merchant.
  2. Search your existing transactions for it and look at every hit.
  3. If a hit belongs in a different category, add one more word to separate them, or choose another piece of text.
  4. If the merchant appears with a different spelling in some rows, add an alias, then base the rule on the alias.

Where do rules fit among the other stages?

SpendixAI applies your own rules first, then your history and similar merchants, and an AI model only if AI is on. That order makes rules your firmest tool: a good rule decides the category before anything is guessed. It also means a poor rule has more influence than you might like, which is another reason to keep them tidy. Custom categories can also carry settings such as a GST rate, so the rule's category choice flows into reports that estimate GST. Those are estimates; confirm figures against invoices and with your CA.

When should I write a rule at all?

  • When the same merchant has turned up three times and you are about to categorise it again.
  • When one merchant is always the same category, such as a utility or a monthly subscription.
  • Not for genuine one-offs, which cost less to categorise by hand than to model.
  • Not for merchants that sell many kinds of things, such as a large marketplace, where one category is often wrong.

Review your rules every few months and delete the ones that never fire.

SPENDIXAI JOURNAL

Useful ideas start with a clearer picture of your own spending.

Explore your reports