To factor $ 2xy-x^2y-6+3x $ we can use factoring by grouping.
Group $ \color{blue}{ 2xy }$ with $ \color{blue}{ -x^2y }$ and $ \color{red}{ -6 }$ with $ \color{red}{ 3x }$ then factor each group.
$$ \begin{aligned} 2xy-x^2y-6+3x &= ( \color{blue}{ 2xy-x^2y } ) + ( \color{red}{ -6+3x }) = \\ &= \color{blue}{ xy( 2-x )} \color{red}{ -3( 2-x ) } = \\ &= (xy-3)(2-x) \end{aligned} $$