Let $X=Y=\mathbb{R}, \mathcal{B}$ the Borel $\sigma$-algebra.
Consider the function $f(x,y)=\begin{cases} 1 & \text{ if } x\geq 0 \text{ and } x\leq y<x+1 \\ -1 & \text{ if } x\geq 0 \text{ and } x+1\leq y<x+2 \\ 0 & \text{ if } else \end{cases}$.
Calculate $\int \int f(x,y) dy dx$ and $\int \int f(x,y) dx dy$.
Are they equal? Why is that example not a contradiction to Fubini?
My attempt: I know that if $E \in \mathcal{A} \times \mathcal{B}$ is a measurable rectangle. Then one can define $h(x)=\mu_1(E_x)$ and $k(y)=\mu_2(E^y)$, where
$E_x:=\{y \in Y:(x,y) \in E\}$ and $E^y:=\{x \in X:(x,y) \in E\}$.
Now if $\mu_1,\mu_2$ are $\sigma$ finite, we have $\int h(x) \mu_1(dx)=\int k(y) \mu_2(dy)$.
In my notes it is stated that we can further wirte the above equality as (which I don't understand why): $\int( \int \chi_E(x,y) \mu_2(dy)) \mu_1(dx)=\int (\int \chi_E(x,y) \mu_1(dx)) \mu_2(dy)$
I would be very happy if someone could explain, how this works.