If you have cost price in A1 and selling price in B1, margin (as often used
in business, although there are different definitions) is given by
=1-A1/B1
This will give a number between 0 and 1. If you format the cell as %, it
will display as between 0% and 100%.
Try this with some example prices to see if you get what you expect. If not,
explain what you understand by margin.