Two small details change totals without any error. The first is which date a chart uses. The second is a missing value.
One date table, many roles
Recap: Dimensional Modeling: Facts & Dimensions joined one dim_date twice. Each join had a role: order date or ship date. There, order 101 was ordered on 2026-01-03 and shipped on 2026-01-10.
Imagine the other paid orders get ship dates too. Order 106 ships on 2026-02-02. Group paid revenue by ship month:
Paid revenue by ship month (imagined dates)worked example
SELECT d.month, SUM(o.amount) AS revenue
FROM paid_orders AS o
JOIN dim_date AS d ON d.full_date = o.ship_date
GROUP BY d.month
ORDER BY d.month;
Result · 2 rows
| month | revenue |
|---|
| 2026-01 | 80.50 |
| 2026-02 | 80.00 |
By order month, January is 160.50. By ship month, it is 80.50. Both are correct for their own date.
Build one view on dim_date for each role, such as dim_order_date and dim_ship_date. The name says which date a person picks. Then no one joins the wrong one.
Unknown values
Dev has no country. In the view, country_at_order is NULL. A filter such as country <> 'IN' drops Dev’s order, because NULL <> 'IN' is not true:
Paid revenue outside IN, with a NULL countryworked example
SELECT SUM(paid_amount) AS revenue
FROM mart_orders
WHERE country_at_order <> 'IN';
The answer should be 25.00 + 15.50 + 80.00 = 120.50. The 80.00 is lost, and no error appears.
The fix is to write a real value, such as Unknown, when the country is not known. Recap: Dimensional Modeling: Facts & Dimensions did this, and added an unknown row with key 0. This dim_customer still holds NULL, so the view must fix it.
The same filter with an Unknown countryworked example
-- In the view: coalesce(c.country, 'Unknown') AS country_at_order
SELECT SUM(paid_amount) AS revenue
FROM mart_orders
WHERE country_at_order <> 'IN';
Now Dev is a visible group called Unknown. A chart shows a bar for it instead of a blank, and the filter keeps the row.
From here on, mart_orders uses this line. coalesce(c.country, 'Unknown') gives the country, or Unknown when the country is NULL.