This document discusses how to optimize reactive compensation in medium voltage systems using consumption analysis and measurements. It recommends logging measurements over at least a week with a network analyzer to determine reactive power consumption profiles. A histogram analysis of the reactive power measurements can then be used to determine the optimal size of steps for a capacitor bank configuration, compensating the majority of consumption. However, the presence of harmonics must also be considered to avoid resonance effects that could damage capacitor banks or affect power quality. Detuned capacitor banks can help reject harmonics and ensure safe compensation.