The chemical formula for a substance shows how many atoms of each element are present in a molecule, or the proportion of atoms of each element. The formula can be worked out using the valency.
Some elements, particularly the transition metals, do not always have the same valency in their different compounds. The valency of these elements is usually given in roman numerals inside brackets.