For discrete measured groupoids preserving a probability measure we introduce a notion of sofic dimension that measures the asymptotic growth of the number of sofic approximations on larger and larger finite sets. In the case of groups we give a formula for free products with amalgamation over an amenable subgroup. We also prove a free product formula for measure-preserving actions.