In words what are you trying to achieve?
It's going wrong....
=IF(L12="", H12, IF(N12<>"", H12-I12-M12, H12-I12, HERE IF(P12<>"",H12-I12-M12-O12, H12-I12-M12)))
An IF condition has TWO results true or false
H12-I12-M12,
Thats your TRUE result
H12-I12,
Thats your FALSE result
The rest of it
IF(P12<>"",H12-I12-M12-O12, H12-I12-M12)))
is the point where its going wrong