As the formula of the substance is known, you should first state the formula of the ions produced when the substance is dissolved into water. Here, $\ce{K_4Fe(CN)_6}$ gets dissolved in water and produced $4$ ions $\ce{K^+}$ so that the $4$ corresponding negative charges must be fixed on the remaining anion, which has the formula $\ce{[Fe(CN)_6]^{4-}}$ with $4$ negative charges. Now you have to think how to synthesize this complex anion from $\ce{1 Fe^x+}$ ion and $\ce{6 CN^-}$ ions. The equation is $$\ce{Fe^{x+} + 6 CN^- -> [Fe(CN)_6]^{4-}}$$ Counting the charges gives x positive charges from $\ce{Fe^{x+}}$, 6 negative charges form the six cyanide ions, and this makes a total of $\ce{4-}$. So the initial $\ce{Fe}$ ion must have been charged $+2$
The nature of the ion $\ce{CN^-}$ remains to be explained : Well ! The carbon atom has 4 independent valence electrons. Nitrogen has 5 valence electrons, but 2 of them are taken in a doublet. So there is only 3 available electrons in N atoms for bonding. When 1 C is attached to 1 N, this makes 3 covalent bonds between C and N. As a consequence one electron is still available on the carbon atom. This is not a stable compound. The carbon atom needs one more electron to get 8 electrons in its outer layer. This electron can be offered by one H atom, which would make a covalent molecule HCN, with one covalence between H and C, and three covalences between C and N. But this last electron can also be given by a sodium Na or a potassium atom K. This would produce the compound NaCN or KCN, where Na (or K) and the carbon atom are bound in a ionic bond between $\ce{Na^+}$ (or $\ce{K^+}$) and the ion $\ce{CN^-}$. This is the origin of the ion cyanide $\ce{CN^-}$.