We develop a calculus for functionals of integer-valued measures, which extends the Functional Itô calculus to functionals of Poisson random measures in a pathwise sense. We show that smooth functionals in the sense of this pathwise calculus are dense in the space of square-integrable (compensated) integrals with respect to a large class of integer-valued random measures. As a consequence, we obtain an explicit martingale representation formula for all square-integrable martingales with respect to the filtration generated by such integer-valued random measures. Our representation formula extends beyond the Poisson framework and allows for random and time-dependent compensators.