The spatial distribution of Al in magnetron sputtered ZnO:Al films has been investigated in depth. Two different kinds of inhomogeneities were observed: an enrichment in the bulk of the film and an enrichment at the interface to the substrate. This has been correlated to the electrical properties of the films: the former inhomogeneities can lead to trap states at the grain boundaries limiting the free carrier mobility. The latter can promote the formation of secondary phases, which leads to an electrical inactivation of the dopant. Furthermore, this effect can contribute to the thickness dependence of the electrical properties of ZnO:Al films.