A quick question. Which data source are you using? I'm assuming you're using excel.
You can get max PO using below mentioned calculated field
Then create a calc field to get the margin.
Workbook has been saved in my public profile. Let me know If you've any question.
Sorry for late reply, but your suggestion works fine. Thank you so much