Condition for exact equation
Check this condition in your head:
Note that $\frac{\partial^2 f}{\partial x\partial y} = \frac{\partial^2 f}{\partial y\partial x}$, so a necessary condition for an exact equation is $$ \frac{\partial P}{\partial y} = \frac{\partial Q}{\partial x}. $$
The theorem below says this is a sufficient condition under certain domains.