The density functional theory (DFT) is a recognised method for the calculation of electronic properties of materials. As such it can also be used for the calculation of energy loss near edge structures. Some care has to be taken since the DFT is intended for ground state calculation. The effect of the core hole left by the excited electron is different in an insulator and in a metal and can be observed in both cases. For an insulator (MgO, Si), a supercell calculation is needed while in the case of copper, extremely good agreement with experiment can be obtained with a partial core hole calculation. In the particular case of the WIEN code (APW method) we show that calculation of low lying edges (Si L at 99 eV) where the initial state is not strongly localised can only be done within the dipole approximation and with some care. Random alloys (CuNi) have been calculated previously using a supercell; we show that a particular version of the virtual crystal approximation gives promising results.