  We study the electronic transport coefficients and the thermoelectric figure
of merit ZT in $n$-doped Mg$_3$Sb$_2$ based on density-functional electronic
structure and Bloch-Boltzmann transport theory with an energy- and
temperature-dependent relaxation time. Both the lattice and electronic thermal
conductivities affect the final ZT significantly, hence we include the lattice
thermal conductivity calculated ab initio. Where applicable, our results are in
good agreement with existing experiments, thanks to the treatment of lattice
thermal conductivity and the improved description of electronic scattering. ZT
increases monotonically in our T range (300 to 700 K), reaching a value of 1.6
at 700 K; it peaks as a function of doping at about 3$\times$10$^{19}$
cm$^{-3}$. At this doping, ZT$>$1 for T$>$500 K.
