A method in connection with a network inverter, an LCL network filter (3) being connected between the network inverter (1) and network (2), and the network inverter being arranged to operate as an active converter of harmonic components of electricity, and the method comprises the steps of forming a current reference (i1, ref) for the network inverter (1) for producing a desired voltage, selecting a harmonic electric component (v), the proportion of which needs to be changed, forming a current reference (i1, refv) altering the selected harmonic component (v), summing the generated current reference (i1, refv) altering the selected harmonic component with the current reference (i1, ref) of the network inverter to produce a summed current reference (i1, ref, tot), and controlling the network inverter with the summed current reference (i1, ref, tot) in a coordinate system bound to the virtual flux linkage of the network inverter by using DTC control.