HMRC guidance is not very clear. To tackle this issue we made a excel template which you may find useful.
If you are carrying forward allowances from past years use HMRC Calculator from HS345 Pension savings — tax charges.
Please drop me an email if you find any errors or wish to suggest any improvements.