Hi yomgi,

Welcome to ExcelFox !!

Try

=IF(P2=1,0,IF(E2=1,18+S2+T2,IF(AND(Q2=1,P2=0),S2+T 2,R2+S2+T2)))