This is an attempt to go further than this answer.
Essentially, we have either a summation of an integral:
$$\sum_x{ \left( \int{ f(x)dx } \right) } \tag{1}$$
...or an integral of a summation:
$$\int{ \left( \sum_x{ f(x) } \right) dx } \tag{2}$$
The answer, without going into detail, states that we can generally interchange the summations and integrations if $f(x)$ is positive. I'm wondering if it's ever possible to interchange summation and integration if $f(x)$ happens to be negative for some values, and what these cases are. I've shown each case separately as (1) and (2), in case that one direction is different than the other.