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