Try: =AVERAGE(IF((A1:A10="X")*((B1:B10="Y")+(C1:C10="Z")),D1:D10))

Confirmed with Ctrl+Shift+Enter as it's an array formula.

Dom