Not entirely sure I follow ...

I think for ex. in your sample A20:A23 should be 0 rather than 1 given 90032A is located in rows 11 & 12 with different POM, no ?
(they are highlighted yellow which based on results I am assuming means you expect a result of 1 ?)

If the above assumption is correct (ie oversight in sample file), one approach:

A2:
=IF(COUNTIF($E$1:$E2,$E2)=1,--(SUMPRODUCT(--($E3:E$100=$E2),--($B3:B$100<>$B2))=0),INDEX($A$1:$A1,MATCH($E2,$E$1:$E1,0)))
copied down

Modify ranges to suit but keep as lean as possible given use of SUMPRODUCT.

Note that in the above the SUMPRODUCT is calculated only once per OrderNo.
Subsequent instances of a given OrderNo use that prior result rather than recalculating (it is an expensive calculation)