The distorted supply voltage degrades the control performance of a unified power quality conditioner (UPQC). This problem causes incorrect calculations in the harmonic identification and reference signal generation processes. This paper proposes a modified harmonic identification of the UPQC. The reference compensating current calculation for the shunt active power filter (shunt APF) is developed using the sliding window with the Fourier analysis (SWFA) method. In addition, the variable power angle control (PAC) is applied to operate the reference signal generation of the series APF and the shunt APF of the UPQC. Under the distorted voltage and nonlinear load conditions, the proposed approach can provide accurate reference compensating signals and successfully share the load reactive power compensation between the shunt APF and the series APF. In this work, a three-phase, three-wire power system with linear and nonlinear loads was implemented. The proposed method was validated using the processor-in-the-loop technique on an eZdsp™ F28335 board and the MATLAB/Simulink program. The testing results indicated that SWFA has excellent filtering performance and enhances harmonic identification compared to the operation without any filter or with low pass filters (LPF). With the proposed approach, the percentage of total harmonic distortion of voltage and current could be maintained within the IEEE519-2022 standard, and the magnitude of the RMS voltage across the load was in the recommended range specified by ANSI C84.1-2016.