Periodic table question

why does mg has the third lowest first ionisation

Magnesium nucleus pulls valence electrons closer to itself, so it has a smaller atomic radius than sodium.

First ionisation energy decreases as you go down the group and increases across the table. Also, first ionisation energy of alkali metals is the lowest, because they are really reactive and want to lose electrons quickly.

Applying that, calcium has the lowest 1st ionisation energy, then sodium, then magnesium and finally boron.