Calculate current using compensation simulate this circuit – Schematic created using CircuitLab

Let's say we know the values of $Z_1$, $Z_2$, $Z_3$. We know the value of $I_3(0)$ - the current in the wire with $Z_3$ and $E_3$ when the switch $S$ is in the position 0. We also know $I_3(1)$ - the same current when the switch is in position 1.

The task is: find $I_3(2)$ - the current $I_3$ when the switch is in position 2. I have tried using the compensation theorem, replacing the wire with $Z_2$ with an ideal current generator, but that didn't work out.

To find $I_3(2)$ you need to know the voltage at the top node (call it $V_t$). Then you know by Ohm's Law that $$I_3(2) = (E_3 - V_t)/Z_3$$
To find $V_t$ you can use superposition (assuming $E_3$, $E_1$, and $I_g$ are independent sources). This requires turning off all sources except one and finding the remaining source's contribution to $V_t$, then repeating until you have found the contribution of all three sources. $V_t$ due to all three sources is then by superposition the sum of the three contributions.
For example, to find the contribution of $E_3$, $E_1$ becomes a short and $I_g$ becomes an open circuit. That means $Z_1$ and $Z_2$ are in parallel, and this parallel resistance is in series with $Z_3$. $V_t$ is then the output of a voltage divider formed by $Z_3$ and $Z_1 \parallel Z_2$.
$E_1$'s contribution is very similar, except $Z_2$ and $Z_3$ are in parallel and this parallel resistance is in series with $Z_1$.
For $I_g$'s contribution, with $E_1$ and $E_3$ off all three impedances are in parallel so $V_t = I_g \times (Z_1 \parallel Z_2 \parallel Z_3)$.