Exact Numbers from Every Route
What this covers
Tessallite can answer the same question in two ways: from the source (your database, row by row) or from an aggregate (a summary table it prepared earlier). This article explains, in plain words, why those two answers could drift apart, what Tessallite does so they always agree, and what you, the modeller, can do to keep tricky numbers safe.
The promise
Ask "total sales for Europe in March" and you get the same number whether Tessallite reads the source or a summary table. A summary table only makes the answer faster. It must never make it different.
How numbers can go wrong (the piggy-bank story)
Imagine you are counting pocket money. You have many coins: €1.25, €0.10, €0.75…
1. Boxes with no room for cents
You sort the coins into boxes, one box per day, and write each day's total on the box. But the label only has room for whole euros. Monday had €1.25, so you write "1". Tuesday had €0.75, so you write "1".
Later someone adds up the labels: 1 + 1 = 2. The real total is €2.00, which happens to agree. Now do the same for 1,000 days: every label can be off by up to 50 cents, and the mistakes pile up. The yearly total from the labels can be hundreds of euros wrong, while counting the real coins gives the exact answer.
That is what happens when a summary table stores money in a number type that has no decimal places. Some databases do exactly that when they are not told how many decimal places to keep.
2. "Almost" numbers
Some number types are like a calculator that is very good but not perfect: ask it for 0.1 + 0.2 and it answers 0.30000000000000004. One tiny slip does not matter, but adding millions of them, in a different order each time, makes the last digits wander. Money should never be stored this way. These types are called floating point (FLOAT, DOUBLE, FLOAT64).
3. Averages of averages
Class A has 2 children who scored 10 and 20 (average 15). Class B has 1 child who scored 30 (average 30). The average of the two averages is (15 + 30) ÷ 2 = 22.5, but the real average of all three children is (10 + 20 + 30) ÷ 3 = 20. You must add up the scores and count the children, then divide — never average the averages.
4. Whole-number division
Some databases treat 7 ÷ 2 as 3 when both numbers are whole numbers (they throw the half away). Others answer 3.5. The same formula can give two answers depending on the database.
What Tessallite does for you
| Problem | What Tessallite does |
|---|---|
| Boxes with no room for cents | A summary table stores every value as exactly as the source keeps it: money with 2 decimal places stays with 2 decimal places, on every database. |
| "Almost" numbers | A value that is exact in the source stays exact in the summary table. Only values that were already floating point in the source stay floating point. |
| Averages of averages | Summary-table averages use total ÷ count. Floating-point averages use the source. |
| Whole-number division | Every division is done as a real division (7 ÷ 2 = 3.5), whatever the database. |
Decimal group keys keep their decimal places too. Two keys that differ in the twelfth decimal place stay separate. If the target database cannot keep those places, the summary build stops with an error.
Averages over floating-point columns use the source because regrouping approximate numbers can change the answer. An unknown average input type also uses the source. A pocket on the source connection can still run the original average over its detail rows.
XMLA whole-number measures use exact signed 64-bit integers. If a result exceeds that range, the cell reports an error instead of silently rounding the result or changing its type.
The transfer check
When a summary table is built in a different database from the source, Tessallite sums numeric columns and records each complete row during transfer. It then reads the new table back to compare totals, row count, and a fingerprint of the group keys and values in every row.
- A mismatch prevents the new artifact from being used. Queries use another eligible route, including the source when available.
- Exact decimal values use exact comparison; values already represented as floating point use the defined numerical error allowance.
- The row check catches equal and opposite value changes, moved values between group keys, missing rows, and duplicate rows even when the numeric totals match. Row order does not matter.
- Matching row fingerprints are very strong evidence, although a hash collision is theoretically possible. The check cannot establish that the original modelling query or access rules were correct; exact storage types and semantic grain checks remain necessary.
Nothing is ever refused and no wrong number is ever shown because of this check: a mismatch only takes the new summary table out of use. The comparison uses the rows actually transferred, so later source changes do not by themselves change the observed input total. Source availability, security and other query limits still apply; the check cannot promise that every fallback request succeeds.
What you can do: make the numbers exact at the source
Tessallite can only keep a number as exact as the source gives it. If a column is stored in an "almost" type, or its type is unknown, give Tessallite an exact type. There are two ways:
Option 1 — A view in the source database
Ask your database team for a view that states the exact type, and point the model at the view instead of the table:
CREATE VIEW sales_clean AS
SELECT order_id,
region,
CAST(amount AS DECIMAL(18, 2)) AS amount -- money: exact, 2 decimal places
FROM sales;
Use this when the same cleaned numbers are useful to other tools too, or when the calculation is heavy (currency conversion, special rounding rules).
Option 2 — A user-defined attribute with an explicit cast
In the model, add a user-defined attribute that casts the column, and build your measure on it:
CAST(amount AS DECIMAL(18, 2))
Use this when you cannot change the source, or the fix belongs to this model only.
Good habits
- Store money and quantities as exact decimals (DECIMAL / NUMERIC with the number of decimal places you need), never FLOAT or DOUBLE.
- When a column's type is unknown or plain
NUMERIC, say how many decimal places it has with a cast. - Do rounding rules (for example "round half to even") and currency conversion at the source, once, so every route starts from the same numbers.
- For a ratio or a percentage, keep the parts (for example profit and revenue) as exact measures and let a calculated measure divide them; Tessallite always divides as a real division.
If a refresh reports a mismatch
The refresh history shows a message such as "Aggregate agg_sales does not hold exactly what the source returned, so it is not used (queries are answered from the source): amount__sum: read 1250.85 from the source, stored total 1251".
- Look at the column named in the message.
- Check its type in the source. If it is floating point or has no decimal places set, apply Option 1 or Option 2 above.
- Refresh the aggregate. When the build passes validation, it becomes eligible again.