  Let $X$ be a Borel metric measure space such that each closed ball is of
positive and finite measure. In this paper, we give a sufficient and necessary
condition for averaging operators on a Banach function space $E(X)$ on $X$ to
be compact. As a corollary, we show that the averaging operators on the Lorentz
space $L^{p,q}(X)$ of $X$ is compact if and only if $X$ is bounded, in the case
where $X$ is a doubling and Borel-regular metric measure space with some
continuity between metric and measure.
