We prove the rationality of the Poincaré series of multiplier ideals in any dimension thus extending the main results for surfaces of Galindo and Monserrat and Alberich-Carramiñana et al. Our results also hold for Poincaré series of test ideals. In order to do so, we introduce a theory of Hilbert functions indexed over R which gives a unified treatment of both cases.