I used an arrayformula with my sumif function which has several criteria and ranges to expand automatically across a set column (B). The formula below works perfectly:
=ARRAYFORMULA(SUMIF('DATA'!$N:$N&'DATA'!$U:$U&'DATA'!$V:$V&'SFDC DATA'!$BV:$BV,$B$6:$B&$E$30&$D$26&$C$36,'DATA'!$AG:$AG).
I want to make it more dynamic and insert an IF statement to actually refer to a range vs another one based on certain conditions. For ex: IF($A$6:$A=XX,'DATA'!$N:$N,'DATA'!$M:$M).
The formula then breaks if I do this =ARRAYFORMULA(SUMIF(IF($A$6:$A=XX,'DATA'!$N:$N,'DATA'!$M:$M)&'DATA'!$U:$U&'DATA'!$V:$V&'SFDC DATA'!$BV:$BV,$B$6:$B&$E$30&$D$26&$C$36,'DATA'!$AG:$AG).
Any way to make it work?