Using Formula for Custom Field

Hi, does anyone know if we can create a Custom Field that uses formula? I want to display Gross Profit percentage on Sales Order DocType but can’t figure out if I can put formula on the “Fetch From” field, or if it’s the right way to do it. Any tips would be appreciated. Thank you in advance.

You need to use the client script to do the calculation in custom field.

https://frappeframework.com/docs/v14/user/en/desk/scripting/client-script