Lagrangian averaging plays an important role in the analysis of wave–mean-flow interactions and other multiscale fluid phenomena. The numerical computation of Lagrangian means, e.g. from simulation data, is, however, challenging. Typical implementations require tracking a large number of particles to construct Lagrangian time series, which are then averaged using a low-pass filter. This has drawbacks that include large memory demands, particle clustering and complications of parallelisation. We develop a novel approach in which the Lagrangian means of various fields (including particle positions) are computed by solving partial differential equations (PDEs) that are integrated over successive averaging time intervals. We propose two strategies, distinguished by their spatial independent variables. The first, which generalises the algorithm of Kafiabad (J. Fluid Mech., vol. 940, 2022, A2), uses end-of-interval particle positions; the second uses directly the Lagrangian mean positions. The PDEs can be discretised in a variety of ways, e.g. using the same discretisation as that employed for the governing dynamical equations, and solved on-the-fly to minimise the memory footprint. We illustrate the new approach with a pseudo-spectral implementation for the rotating shallow-water model. Two applications to flows that combine vortical turbulence and Poincaré waves demonstrate the superiority of Lagrangian averaging over Eulerian averaging for wave–vortex separation.