Valency helps in determining the formula of an ionic compound. Valency can be used to ind out how the atoms of an element will combine with the atoms of another element to form a compound.
For example: Magnesium chloride
By applying criss-cross method:

Formula: MgCl2
Thus, the formula for magnesium chloride is MgCl2 .