We report on the possible origin of electrical heterogeneities in 4 at% Al-doped ZnO (AZO) reactively sputtered films. It is found through the Zn L-3 and Al K edge x-ray absorption near-edge structure that a fraction of the Al dopant is deactivated by its positioning in octahedral conformation with oxygen. This fraction as well as the conductivity, optical bandgap and c-axis parameter of ZnO wurtzite are all found to depend on the sample position during deposition. The present results suggest the formation of a metastable Al2O3 (ZnO) m homologous phase that degrades the electrical conductivity.