The left column is the cost, the gross profit and the selling price, top to bottom. The gross profit is the price minus the cost. Of the two cards on the right, the upper one is the markup and the lower one the margin; both are worked out from the gross profit in the middle of the left column.
Changing the cost or the price updates the gross profit and both percentages. The example uses nothing but a cost and a price, to keep the comparison clean.
The same profit, divided by the price or by the cost
The gross profit here is 100 − 80 = 20. Up to this point, both percentages agree.
margin (%) = gross profit ÷ selling price × 100
Margin says what share of the selling price is profit. The price of 100 counts as 100%, so 20 ÷ 100 gives 20%. It is also called the gross margin or gross profit margin.
markup (%) = gross profit ÷ cost × 100
Markup says how much was added on top of the cost. The cost of 80 counts as 100%, so 20 ÷ 80 gives 25%.
The same profit of 20 is divided by 100 in one case and by 80 in the other, hence 20% and 25%. Both are correct; they measure against different amounts. As long as the price is above the cost, the markup, with its smaller divisor, is always the larger of the two.
The percentages depend on the ratio of cost to price, not on the size of the amounts. With the cost on Board 1 set to 800 and the price to 1,000, the gross profit becomes 200, and the margin and markup stay at 20.0% and 25.0%.
The gross profit is part of the price, so as long as the cost is above 0, the margin never reaches 100%. Markup has no such ceiling. With a cost of 80 and a price of 160, the margin is 50.0% and the markup 100.0%. Selling at twice the cost is exactly a 100% markup.
Setting a price from a target — the same 20% gives different prices
The calculation also works the other way: from a percentage decided first, it gives the price. Board 2 starts from a cost of 80 and works out one price from a target margin and another from a target markup. Both targets are set to 20%.