No formula, really. The conductive losses can be estimated by Ohm's law, the ON resistance times the current. The switching losses depend on layout. During the switching time, the transient voltage and current in each part multiplied by the duration, divided by the frequency.
Long leads make switching time longer and voltages spike.