What is the reason that in measure fields in fact tables (dimensionally modeled data warehouses) NULL values are usually mapped as 0?
NULL instead of 0 should be used if you intend to do an average on your fact column. This is the only time i believe NULLS are ok in a dwh fact or dimensions
if a fact value is unknown/late arriving, then leaving as NULL is best.
aggregate functions suchs as MIN,MAX work on NULLS simply ignoring them
(For the record one of Ralph Kimball's sidekicks said this in his course I intended)
with goodf as
(
select 1 x
union all
select null
union all
select 4
)
select sum(x) sumx,min(x) minx,max(x) maxx,avg(cast(x as float)) avgx
from goodf
with badf as
(
select 1 x
union all
select 0 /* unknown */
union all
select 4
)
select sum(x) sumx,min(x) minx,max(x) maxx,avg(cast(x as float)) avgx
from badf
in badf above the average comes out incorrect as it uses the zero of the unknown value as literally 0