The following formula looks like it should work but I keep getting errors.
=IF(S4=1,AVERAGEIFS($Q$4:$Q$64,$S$4:$S$64,1,ROW($S$4:$S$64),”>=”&ROWS($S$4:$S$64)-19),AVERAGEIFS($Q$4:$Q$64,$S$4:$S$64,0,ROW($S$4:$S$64),”>=”&ROWS($S$4:$S$64)-9))
Q4-Q64 has daily revenue for the last 60 Days, S4-S64 have a 1 for every workday and 0 for every weekend or holiday. If its a workday it needs to take the last 20 work days for an average. If its a weekend or holiday it needs to take the last 10 weekends or holidays for the average.