This is not available out of the box. It would require a Discount Requirement like: "Customer has in cart X to Y items of any of these products: p1, p2, p3,...". For your case you will need to set 2 requirements; one for Category 1 and the other for category 2 and group them in AND requirement (available in v3.90).