To calculate margin you have to use formula:

cost/ 100 - (xx% of margin) x 100= price
For example:

Purchase price =100
margin you want to add = 30%

So 100 / 70 x 100 = 142.85