What we learned building Rai's metric catalog

Rai does not invent its sums. It picks from a catalog of business metrics we define and test. Building that catalog taught us more about shops than about AI.

A laptop showing a metric definition for gross margin by item, with its formula, period and the question it answers

Ask ten shop owners "how much did I make last month?" and you will get at least two meanings. Some mean sales: the money that came through the till. Others mean profit: what was left after paying suppliers. An analyst that answers the first when you meant the second gives you a correct figure and a wrong answer, and a careful owner will stop trusting it after one such reply.

That gap is a fair summary of why Rai has a metric catalog. Rai, the AI analyst inside UpeoRetail, does not make up the arithmetic behind its answers. When you ask a question, the reasoning part of Rai chooses from a set of business metrics we have defined, named and tested, and the connector on your server computes them from your own records. We wrote about that split in your business data never leaves your server.

Building the catalog was mostly not an AI problem. Here is what we learned.

One word, many meanings#

The first surprise was how many everyday words in a shop have several honest meanings.

"Sales" can mean invoices raised, money received, or invoices minus returns. "Stock" can mean what the system says, what was last counted, or what is available after reserved orders. "Margin" can mean margin on price or markup on cost, which is a mix-up we have written about before.

None of these is wrong. The problem is using one word for two of them. So every metric in the catalog has one name and one meaning, and the answer says which meaning it used. When an owner asks for "sales", the reply should say which sales it means, for example "net sales after returns", so the owner can object if he meant something else.

Most wrong numbers we found were not calculation errors. They were two people meaning different things by the same word.

Every number needs a period and a source#

A figure without a period is a rumour. "Margin is 18%" invites the question: since when? The catalog gives every metric a period, and the answer should state it: "October", "last 90 days", "since the price change on 4 August".

Each metric also records where its inputs come from. Cost of goods, for example, comes from what you paid on purchase invoices. When a shop has items with no purchase cost recorded, the honest answer is to say so, not to guess. A reply like "margin excludes 23 items with no recorded cost" is less tidy than a single confident figure, but it is true, and it points the owner at the records that need fixing.

Small definitions decide big answers#

Some of the hardest decisions were tiny ones:

  • Returns. Is a return taken off the month of the original sale, or the month it came back? Both are defensible. What is not defensible is choosing silently, so the answer has to say which.
  • Dead stock. How many days without a sale makes an item "dead"? The answer depends on the shop. A spare-parts dealer and a phone accessories shop have very different rhythms, so the period cannot be one fixed number for everyone, and it belongs in the answer.
  • Fast movers. By units, by value, or by margin? Each gives a different list. The answer should say which it is ranking by.

These choices sound like detail. They are the difference between an answer the owner trusts and one he quietly ignores.

Testing the meaning, not only the maths#

Each metric has tests with known inputs and known answers: a small made-up shop where we know exactly what the margin on cement should be. If a change to the system moves that answer, the test fails before any owner sees it. We described the approach in regression tests for AI answers.

We also test the step before the maths: given a question in plain English, Swahili or Sheng, does Rai pick the right metric? "Nimeuza ngapi wiki hii?" should map to sales for this week, not stock movement. This step deserves as much testing as the maths, because a perfect sum of the wrong metric is still the wrong answer.

What this means for you#

You may never build a metric catalog. But the lessons apply to any report you read, from any system or any person:

  1. Ask what each word means. When someone says "sales", ask: before or after returns?
  2. Ask for the period. No period, no decision.
  3. Ask what was left out. Items without a cost, branches not included, days missing.
  4. Write your own definitions down. One page, your words: what you mean by sales, margin and dead stock. Give it to whoever prepares your numbers.

This is stage 4 on the NGAZI ladder, AI on your accumulated history, and it only works because the history is defined first.

What to do this week#

Write down, in one sentence each, what you mean by sales, margin and stock. Then ask the person or system that gives you reports whether they use the same meanings. If the answer is "I am not sure", you have found the cause of at least one argument about numbers.

All posts

Want this working in your business?

We build the AI systems we write about - for retail, clinics, workshops and property businesses across Africa. Tell us what you run and we will be honest about where it helps.