Data Modeling
Unit conversions in analytical models should preserve both the original measurement and the normalized value. The normalized value makes reporting easier; the original unit and conversion provenance make the number explainable, auditable, and repairable when a conversion rule changes or an upstream system sends mixed units.
The direct answer: store both the measurement and the conversion
A good analytical model does not overwrite the original unit with a converted value. It stores the original value, original unit, normalized value, normalized unit, conversion factor, conversion method, and conversion rule version side by side.
This gives analysts one value that is safe to compare and aggregate, while preserving the evidence needed to answer basic questions later:
- What did the source system originally say?
- Which unit did the source value use?
- What standard unit did the model convert it into?
- Which factor or formula was applied?
- Was the conversion exact, rounded, inferred, defaulted, or manually corrected?
- Can the normalized value be reproduced from stored fields?
The simplest operator rule is this: normalize for analysis, retain for truth. The normalized number supports consistent reporting. The retained original measurement protects the data lineage of the reported number.
Normalize values for comparison, but never destroy the original measurement. The original value and unit are part of the fact, not temporary staging debris.
Why original units matter after normalization
It is tempting to convert every measurement into one standard unit and discard the source unit. That makes the table look cleaner, but it removes information that often becomes important later.
Original units matter because unit errors are usually silent. A value of 10 is not obviously wrong until you know whether it means 10 pounds, 10 kilograms, 10 cases, 10 liters, or 10 gallons. If the model only keeps the converted result, investigators may not be able to tell whether the source was wrong, the mapping was wrong, or the conversion was wrong.
Preserving original units is especially important when:
- Multiple source systems use different unit conventions.
- Users can manually enter measurements.
- Products, materials, or locations have default units that change over time.
- Conversions depend on product-specific density, packaging, temperature, or count-per-case assumptions.
- Historical facts must not be reinterpreted automatically when master data changes.
Dimensional modeling practice has long treated multiple units of measure as a modeling issue, not only a calculation issue. The durable idea is that facts need enough measurement context to remain meaningful after they leave the source system.
Model the measurement, not just the number
A measurement is not a naked numeric value. It is a value expressed in a unit under a rule. Analytical models should represent that full idea.
For example, this source record is incomplete for analytics:
quantity = 25
This record is better:
quantity_value = 25, quantity_unit = lb
This record is better still for an analytical model:
original_quantity_value = 25, original_quantity_unit = lb, normalized_quantity_value = 11.33980925, normalized_quantity_unit = kg, conversion_factor = 0.45359237, conversion_rule_id = mass_lb_to_kg_v1
The first version can be displayed, but not safely interpreted. The second can be interpreted, but still requires downstream logic to compare it with other records. The third can be aggregated in kilograms while still showing exactly how it came from the source measurement.
Minimum fields for a unit-aware fact
The exact column names depend on your modeling standards, but the model should separate four concerns: source measurement, normalized measurement, conversion provenance, and quality flags.
For many analytical facts, the minimum useful pattern looks like this:
- Original value: the numeric value from the source record.
- Original unit: the unit code from the source record or the resolved source context.
- Normalized value: the converted value used for standard reporting.
- Normalized unit: the target unit used by the model.
- Conversion factor or formula: the factor or transformation applied.
- Conversion rule identifier: a stable ID for the rule, mapping, or version.
- Conversion source: where the conversion rule came from, such as reference data, product master data, or a controlled mapping table.
- Conversion quality flag: whether the conversion was exact, inferred, defaulted, missing, manually overridden, or not applicable.
Do not rely on column names alone to express this meaning. A field named weight or amount is ambiguous unless the model documents its unit and grain.
| Field | Purpose | Common failure if missing |
|---|---|---|
| original_value | Preserves the source measurement. | You cannot verify whether the converted number reflects the source. |
| original_unit | Explains what the source value meant. | A value like 10 becomes ambiguous. |
| normalized_value | Provides the standard value for reporting and aggregation. | Dashboards may mix incompatible units. |
| normalized_unit | Names the standard reporting unit. | Users may not know how to interpret the normalized value. |
| conversion_rule_id | Connects the row to the applied rule or version. | Rule changes cannot be audited or reproduced. |
| conversion_quality_flag | Shows whether the conversion was exact, inferred, defaulted, or corrected. | Low-confidence conversions look the same as clean conversions. |
Explicit calculation rules prevent silent drift
Unit conversion logic should be deterministic enough that a practitioner can recompute the normalized value from stored fields or a versioned conversion table.
For simple multiplicative conversions, use a rule like this:
normalized_value = original_value × conversion_factor_to_normalized_unit
Hypothetical example:
- Original value: 25
- Original unit: lb
- Normalized unit: kg
- Conversion factor: 0.45359237
- Calculation: 25 × 0.45359237 = 11.33980925 kg
That example is straightforward because pounds to kilograms is a simple mass conversion. Not every conversion is that simple. Some require additive offsets, product-specific ratios, or context from a dimension table.
Temperature is a common counterexample to the idea that all conversions are simple multiplications:
- 10 degrees Celsius is 50 degrees Fahrenheit.
- The formula is not 10 multiplied by a constant.
- The conversion requires both scaling and an offset.
If your conversion can require a formula, do not store only a generic factor column and hope it covers every case. Store a conversion method or rule ID that points to the correct method.
Do not assume every unit conversion is a single multiplier. Some conversions require formulas, offsets, product attributes, density assumptions, or package definitions.
Numeric counterexamples: how unit mistakes distort aggregates
Unit mistakes often look small at the row level and large at the aggregate level. The danger is not only that an individual record is wrong; it is that a dashboard can confidently summarize incompatible measurements.
Consider a hypothetical shipment fact table with three rows:
- Shipment A: 10 kg
- Shipment B: 10 lb
- Shipment C: 10 kg
If a report sums the raw values without units, it returns 30. That number is meaningless because it mixes kilograms and pounds. If the reporting unit is kilograms, the correct normalized sum is:
- Shipment A: 10 kg
- Shipment B: 10 × 0.45359237 = 4.5359237 kg
- Shipment C: 10 kg
- Total: 24.5359237 kg
The raw sum overstates the kilogram total by 5.4640763 kg. That is an error of about 22.3 percent relative to the normalized total.
A second counterexample involves averages. Suppose two package weights are recorded as 1 kg and 1 lb. The naive average of raw values is 1. The normalized average in kilograms is:
- 1 kg = 1 kg
- 1 lb = 0.45359237 kg
- Average = 0.726796185 kg
The raw average appears tidy, but it has no valid unit. This is why unit conversion belongs before aggregation, not after aggregation.
Convert before aggregating. A sum or average of mixed original units is usually not a meaningful business number, even if the SQL runs successfully.
| Calculation | Naive approach | Unit-aware approach |
|---|---|---|
| Sum | Add raw numeric values regardless of unit. | Convert each row to the target unit, then sum normalized values. |
| Average | Average raw numeric values across mixed units. | Convert each row first, then average normalized values. |
| Minimum or maximum | Compare raw values directly. | Compare values only after conversion to a common unit. |
| Rate using quantity | Use mixed-unit quantity in the denominator or numerator. | Use a normalized quantity with a documented unit. |
Preserve conversion provenance with stable rule versions
Conversion provenance is the record of how a normalized value was produced. It should be stable enough that a historical fact remains interpretable even after reference data changes.
A useful conversion rule record often includes:
- A stable conversion rule ID.
- The source unit and target unit.
- The conversion method, such as multiplicative factor, formula, or product-specific ratio.
- The factor or formula parameters.
- The effective date range, when relevant.
- The source of the rule, such as a controlled reference table.
- The rule version or change reason.
For analytical facts, be careful with retroactive changes. If a conversion rule was wrong, you may need to restate normalized values. If a conversion rule was correct at the time but later replaced by a better business convention, you may need both historical reproducibility and a current restatement view.
The key is not to hide that choice. A model should make it clear whether a normalized value is an immutable historical conversion or a recalculated current interpretation.
Choose numeric representation deliberately
Unit conversion can amplify numeric representation problems. A model that converts millions of rows from one unit to another should not casually round at every stage.
Practical rules:
- Keep original values at the precision provided by the source, unless there is a documented reason not to.
- Use decimal numeric types for measurements where fixed precision matters to reporting or reconciliation.
- Avoid repeated conversion chains such as pounds to kilograms to grams to kilograms. Convert from the original value to the reporting unit using a controlled rule.
- Round for presentation separately from storage when possible.
- Store enough precision in the normalized value to support downstream aggregation without avoidable rounding loss.
For example, if each row rounds 0.45359237 kg to 0.45 kg, then 10,000 one-pound rows sum to 4,500 kg instead of 4,535.9237 kg. The row-level difference looks small. The aggregate difference is 35.9237 kg.
Validation tests for unit conversion models
Unit-aware models should have tests that catch both missing context and impossible calculations. These tests do not need to be elaborate to be useful.
Start with these checks:
- Unit presence: every non-null original measurement has an original unit.
- Allowed unit: original units belong to an approved unit reference table.
- Target unit consistency: each normalized field uses the expected reporting unit.
- Conversion rule presence: converted rows have a conversion rule ID or documented reason for not needing one.
- Recalculation tolerance: normalized value equals original value transformed by the stored rule within an acceptable tolerance.
- Quality flag completeness: inferred, defaulted, missing, and manually corrected conversions are visible in the data.
- Aggregation guardrail: semantic models and dashboard layers aggregate normalized values, not mixed original values.
Also test for suspicious distributions. If one warehouse usually records weights in kilograms and suddenly sends a high volume of pounds, the values may still pass type checks while failing business expectations.
A practical modeling pattern
A durable implementation separates facts from reference rules without making every query painful.
Use the fact table to store the measurement as used by analytics:
- Original value and original unit.
- Normalized value and normalized unit.
- Conversion rule ID used at processing time.
- Conversion quality flag.
Use a conversion rule table to store rule details:
- Source unit.
- Target unit.
- Factor or formula parameters.
- Rule method.
- Effective dates, if the business requires them.
- Version and status.
This pattern supports common reporting without requiring every dashboard to reimplement conversion logic. It also gives analysts a path back to the rule details when a number is challenged.
For business concepts with multiple valid analytical units, consider storing more than one normalized fact only when each has a clear purpose. For example, an operations model might need both normalized mass and normalized package count. Do not create extra converted columns simply because they are easy to calculate.
Operator checklist before publishing the model
Before exposing a unit-converted model to dashboards, walk through the model as if a skeptical operator is challenging one number.
- Can you show the original value and original unit for the row?
- Can you show the normalized value and normalized unit used in reporting?
- Can you identify the conversion rule that produced the normalized value?
- Can you recompute the normalized value from stored data or versioned rules?
- Can you tell whether the unit was explicit, inferred, defaulted, or corrected?
- Can you prevent users from summing mixed original units by accident?
- Can you explain the rounding policy for stored values and displayed values?
- Can you handle records that have missing or unsupported units without silently converting them to zero?
- Can you preserve historical meaning if a conversion rule changes?
If the answer to several of these questions is no, the model may still produce numbers, but it is not yet safe for trusted analytical use.
Key takeaways
- A unit-converted analytical model should keep original value, original unit, normalized value, normalized unit, and conversion provenance together.
- The normalized value is for comparison and aggregation; the original measurement is for interpretation, auditability, and repair.
- Convert at the row level before aggregating. Aggregating mixed original units produces numbers that may be syntactically valid but analytically meaningless.
- Store rule IDs, methods, factors, and quality flags so conversion logic can be reproduced and challenged.
- Treat rounding and numeric precision as modeling decisions, not display details.
Next step
Pick one existing fact table that contains a physical measurement. Add a small data profile that lists every unit observed, the intended normalized unit, the conversion rule source, and whether each row can be recomputed from stored fields. Use the gaps to define the minimum columns and tests your model needs.
- Read Currency Conversion Dates in Reporting: How to tell whether a number should use the transaction date rate or the reporting date rate before it reaches a dashboard.
- Read Fixed-Point Decimal Precision and Scale: How to Choose Capacity: A practical guide to sizing decimal columns and calculation outputs so stored values, sums, products, and ratios do not overflow or silently lose useful detail.
- Read Data Modeling Before Dashboards: Build Metrics People Can Trust: Use business definitions, entities, events, and trusted marts before investing in dashboard polish.