Let $(X,\Sigma,\mu)$ be a finite measure space with $f\in L^1$. Let $\Sigma'\subset\Sigma$ be a sub sigma algebra. I want to show the existence of $g:X\to\mathbb{R}$ such that $g$ is $\Sigma'$ measurable with $$ \int_A g\ d\mu = \int_A f\ d\mu $$ for $A\in\Sigma'$.
My attempt. I want to take $g=f$ a.e. so that the integral condition is easily satisfied. However this does not make $g$ $\Sigma'$-measurable, only $\Sigma$ measurable. To fix this, I'm thinking to take $$ g = \begin{cases} \infty,\ \text{ on null sets in }\Sigma' \\ f,\ \text{ else} \end{cases} $$ Will this make $g$ $\Sigma'$ measurable? I.e. is $g^{-1}((\alpha,\infty])\in\Sigma'$ for all $\alpha\in\mathbb{R}$? I don't think so but I'm stuck with what to do if not.
Use the Radon-Nikodym theorem.
First, define $\nu$ on $(X, \Sigma')$ by $$\nu(A) = \int_A f d\mu$$ for all $A \in \Sigma'$. Let $\mu'$ be the restriction of $\mu$ to $(X, \Sigma')$.
We have $\nu \ll \mu'$, so by Radon-Nikodym, there exists an integrable function $g$ on the measurable space $(X, \Sigma')$ that satisfies $$\nu(A) = \int_A g d\mu'$$ for all $A \in \Sigma'$. But $\int_A g d\mu' = \int_A g d\mu$ just by the definition of the integral, and so $$\int_A gd\mu = \int_A f d\mu.$$
Incidentally, in probability $g$ is called a conditional expectation and so we proved that conditional expectations always exist.