Hi,
Currently I am averaging values that match ANY OF 4 different benchmarks. My first solution was to do a seperate SUMIF for each benchmark and add their total. Then divide that result by the sum of 4 seperate Countif functions to arrive at the average.
I am looking for a way to use a criteria such that a data in the range must belong to any of the benchmarks using only 1 countif and 1 sumif function, instead of 4 of each.
I think the answer lies in the correct usage of the OR function to check whether a value is 1 bechmark or the other, or the other, or the other etc
Here is one such function. Here, K2,K3,K4 and K5 represent the 4 different benchmarks. A5 and B5 represet the date range the data must be in. I know that SUMIF and COUNTIF operate like AND funcaitons such that all criteria must be met, but finding a way to use OR would make this code a lot cleaner
=(SUMIFS(June!$F$2:$F$65536,June!$D$2:$D$65536,"<="&B5,June!$D$2:$D$65536,">="&A5,June!$C$2:$C$65536,$K$2)+
SUMIFS(June!$F$2:$F$65536,June!$D$2:$D$65536,"<="&B5,June!$D$2:$D$65536,">="&A5,June!$C$2:$C$65536,$K$3)+
SUMIFS(June!$F$2:$F$65536,June!$D$2:$D$65536,"<="&B5,June!$D$2:$D$65536,">="&A5,June!$C$2:$C$65536,$K$4)+
SUMIFS(June!$F$2:$F$65536,June!$D$2:$D$65536,"<="&B5,June!$D$2:$D$65536,">="&A5,June!$C$2:$C$65536,$K$5))
/
(COUNTIFS(June!$D$2:$D$65536,"<"&B5,June!$D$2:$D$65536,">="&A5,June!$C$2:$C$65536,$K$2)+
COUNTIFS(June!$D$2:$D$65536,"<"&B5,June!$D$2:$D$65536,">="&A5,June!$C$2:$C$65536,$K$3)+
COUNTIFS(June!$D$2:$D$65536,"<"&B5,June!$D$2:$D$65536,">="&A5,June!$C$2:$C$65536,$K$4)+
COUNTIFS(June!$D$2:$D$65536,"<"&B5,June!$D$2:$D$65536,">="&A5,June!$C$2:$C$65536,$K$5))
If you need more explanation or examples, please let me know. Thanks!
Bookmarks