We present a novel generic tool for data compression and filtering: the generalized Karhunen-Loeve(GKL) transform. The GKL transform minimizes a distance between any given reference and a transformation of some given data where the transform has a predetermined maximum possible rank. The GKL transform is also a generalization of the relative Karhunen-Loeve (RKL) transform by Yamashita and Ogawa (see IEEE Trans. Signal Processing, vol.44, p.661-72, Mar. 1996) where the latter assumes that the given data consist of the given reference (signal) and an independent noise. This letter provides a very simple and yet complete description of the GKL transform and shows useful engineering insights into the GKL transform.