SOLVED

best way to find max and average values for data that meets certain criteria

%3CLINGO-SUB%20id%3D%22lingo-sub-1057551%22%20slang%3D%22en-US%22%3Ebest%20way%20to%20find%20max%20and%20average%20values%20for%20data%20that%20meets%20certain%20criteria%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1057551%22%20slang%3D%22en-US%22%3E%3CP%3EI%20have%20a%20table%20with%20names%20in%20column%20B%20and%20dates%20in%20row%201.%20The%20rest%20of%20the%20tables%20is%20the%20sales%20amount%20for%20the%20employee%20listed%20in%20column%20B%20on%20the%20date%20in%20row%201.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20want%20to%20find%20the%20max%20and%20the%20average%20for%20certain%20days.%20For%20example%20we%20have%2012%20sales%20on%20various%20days%20a%20quarter.%20I%20want%20to%20be%20able%20to%20find%20the%20max%20sales%20amount%20on%20days%20days%20that%20we%20had%20sales%2C%20and%20the%20days%20we%20didn't%20have%20sales%20as%20well%20as%20the%20averages%20sales%20amount%20on%20the%20days%20we%20had%20sales%20and%20the%20days%20we%20didn't%20have%20sales.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20can%20find%20the%20row%20that%20the%20data%20is%20in%20using%20match%3A%20%3DMATCH(A2%2Cdata!B%3AB%2C0)%20I%20can%20find%20the%20if%20is%20a%20sale%20using%20max%20and%20maxifs%20in%20an%20arrary%3A%20%7B%3DMAX(MAXIFS(data!%24C2%3A%24N2%2Cdata!%24C%241%3A%24N%241%2Creport!%24M%241%3A%24P%241))%7D%20or%20using%20%3DAGGREGATE(14%2C4%2CMAXIFS(data!%24C2%3A%24N2%2Cdata!%24C%241%3A%24N%241%2Creport!%24M%241%3A%24P%241)%2C1)%3C%2FP%3E%3CP%3EThere%20is%20a%20problem%20with%20finding%20the%20max%20if%20it%20is%20not%20a%20sale.%20I%20am%20not%20sure%20why.%20I%20tried%3A%20%3DAGGREGATE(14%2C4%2CMAXIFS(data!%24C2%3A%24N2%2Cdata!%24C%241%3A%24N%241%2C%22%26lt%3B%26gt%3B%22%26amp%3Breport!%24M%241%3A%24P%241)%2C1)%20%26amp%3B%20%7B%3DMAX(MAXIFS(data!%24C2%3A%24N2%2Cdata!%24C%241%3A%24N%241%2C%22%26lt%3B%26gt%3B%22%26amp%3Breport!%24M%241%3A%24P%241))%7D%3C%2FP%3E%3CP%3EI%20can%20find%20the%20average%20if%20it%20is%20a%20sale%20if%20there%20is%20data%20for%20every%20day%2C%20but%20not%20if%20there%20is%20data%20missing.%20Then%20I%20get%20a%20%23DIV%2F0%20error.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EAny%20ideas%20on%20this%3F%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-1057551%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EExcel%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EFormulas%20and%20Functions%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1057691%22%20slang%3D%22en-US%22%3ERe%3A%20best%20way%20to%20find%20max%20and%20average%20values%20for%20data%20that%20meets%20certain%20criteria%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1057691%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F92549%22%20target%3D%22_blank%22%3E%40Jay%20Lea%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3EYou%20may%20try%20this...%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EIn%20C2%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-markup%22%3E%3CCODE%3E%3DMAX(MAXIFS(INDEX(data!%24C%242%3A%24N%2413%2CMATCH(%24A2%2Cdata!%24B%242%3A%24B%2413%2C0)%2C)%2Cdata!%24C%241%3A%24N%241%2Creport!%24M%241%3A%24P%241))%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EIn%20D2%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-markup%22%3E%3CCODE%3E%3DMAX(MAXIFS(INDEX(data!%24C%242%3A%24N%2413%2CMATCH(%24A2%2Cdata!%24B%242%3A%24B%2413%2C0)%2C)%2Cdata!%24C%241%3A%24N%241%2C%22%26lt%3B%26gt%3B%22%26amp%3Breport!%24M%241%3A%24P%241))%3C%2FCODE%3E%3C%2FPRE%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1057739%22%20slang%3D%22en-US%22%3ERe%3A%20best%20way%20to%20find%20max%20and%20average%20values%20for%20data%20that%20meets%20certain%20criteria%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1057739%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F92549%22%20target%3D%22_blank%22%3E%40Jay%20Lea%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EAs%20variant%3C%2FP%3E%0A%3CP%3EMax%20If%20Sale%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-markup%22%3E%3CCODE%3E%3DAGGREGATE(14%2C6%2C1%2F--ISNUMBER(MATCH(data!%24C%241%3A%24N%241%2C%24M%241%3A%24P%241%2C0))*INDEX(data!%24C%242%3A%24N%2413%2CMATCH(%24A2%2Cdata!%24B%242%3A%24B%2413%2C0)%2C0)%2C1)%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3EMax%20If%20Not%20Sale%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-markup%22%3E%3CCODE%3E%3DAGGREGATE(14%2C6%2C1%2F--NOT(ISNUMBER(MATCH(data!%24C%241%3A%24N%241%2C%24M%241%3A%24P%241%2C0)))*INDEX(data!%24C%242%3A%24N%2413%2CMATCH(%24A2%2Cdata!%24B%242%3A%24B%2413%2C0)%2C0)%2C1)%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3EAverage%20if%20sale%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-markup%22%3E%3CCODE%3E%3DSUMPRODUCT(ISNUMBER(MATCH(data!%24C%241%3A%24N%241%2C%24M%241%3A%24P%241%2C0))*INDEX(data!%24C%242%3A%24N%2413%2CMATCH(%24A2%2Cdata!%24B%242%3A%24B%2413%2C0)%2C0))%2FSUMPRODUCT(ISNUMBER(MATCH(data!%24C%241%3A%24N%241%2C%24M%241%3A%24P%241%2C0))*(INDEX(data!%24C%242%3A%24N%2413%2CMATCH(%24A2%2Cdata!%24B%242%3A%24B%2413%2C0)%2C0)%26lt%3B%26gt%3B0))%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3EAverage%20if%20Not%20Sale%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-markup%22%3E%3CCODE%3E%3DSUMPRODUCT(NOT(ISNUMBER(MATCH(data!%24C%241%3A%24N%241%2C%24M%241%3A%24P%241%2C0)))*INDEX(data!%24C%242%3A%24N%2413%2CMATCH(%24A2%2Cdata!%24B%242%3A%24B%2413%2C0)%2C0))%2FSUMPRODUCT(--NOT(ISNUMBER(MATCH(data!%24C%241%3A%24N%241%2C%24M%241%3A%24P%241%2C0)))*(INDEX(data!%24C%242%3A%24N%2413%2CMATCH(%24A2%2Cdata!%24B%242%3A%24B%2413%2C0)%2C0)%26lt%3B%26gt%3B0))%3C%2FCODE%3E%3C%2FPRE%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1058658%22%20slang%3D%22en-US%22%3ERe%3A%20best%20way%20to%20find%20max%20and%20average%20values%20for%20data%20that%20meets%20certain%20criteria%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1058658%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F92549%22%20target%3D%22_blank%22%3E%40Jay%20Lea%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3EIf%20your%20definition%20of%20best%20is%20%22the%20shortest%22%2C%20I%20will%20recommend%20this%20formula%20in%20C2%2C%20as%20shown%20in%20the%20snapshot%20below%3A%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20400px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F160937iE693D3323AC83527%2Fimage-size%2Fmedium%3Fv%3D1.0%26amp%3Bpx%3D400%22%20alt%3D%22clipboard_image_0.png%22%20title%3D%22clipboard_image_0.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3EDelving%20into%20the%20attached%20file%2C%20you'll%20see%20this%20formula%20in%20G2%3A%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSTRONG%3E%3DSUMPRODUCT(COUNTIF(%24M%241%3A%24P%241%2Cdata!%24C%241%3A%24N%241)*%3C%2FSTRONG%3E%3CBR%20%2F%3E%3CSTRONG%3EINDEX(data!%24C%242%3A%24N%2413%2CMATCH(%24A2%2Cdata!%24B%242%3A%24B%2413%2C0)%2C0))%2F%3C%2FSTRONG%3E%3CBR%20%2F%3E%3CSTRONG%3ESUMPRODUCT(COUNTIF(%24M%241%3A%24P%241%2Cdata!%24C%241%3A%24N%241*%3C%2FSTRONG%3E%3CBR%20%2F%3E%3CSTRONG%3E(INDEX(data!%24C%242%3A%24N%2413%2CMATCH(%24A2%2Cdata!%24B%242%3A%24B%2413%2C0)%2C0)%26lt%3B%26gt%3B%22%22)))%3C%2FSTRONG%3E%3C%2FP%3E%3CP%3ENote%20that%20I%20used%20the%20%3CSTRONG%3Eelegant%20COUNTIF%3C%2FSTRONG%3E%20instead%20of%20the%20%3CSTRONG%3Efamiliar%20ISNUMBER-MATCH%3C%2FSTRONG%3E%20combination.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1059981%22%20slang%3D%22en-US%22%3ERe%3A%20best%20way%20to%20find%20max%20and%20average%20values%20for%20data%20that%20meets%20certain%20criteria%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1059981%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F394231%22%20target%3D%22_blank%22%3E%40Subodh_Tiwari_sktneer%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThe%20one%20for%20C2%20worked%20perfectly%2C%20but%20the%20one%20for%20D2%20did%20not.%20The%20%22%26lt%3B%26gt%3B%22%26amp%3B%20doesn't%20give%20an%20error%20but%20it%20doesn't%20seem%20to%20be%20working.%26nbsp%3B%20%26nbsp%3BYou%20are%20doing%20it%20they%20way%20I%20wanted%20to%20do%20it.%20I%20wasn't%20sure%20how%20to%20do%20an%20index%20match%20with%20maxifs%2C%20but%20it%20is%20working.%26nbsp%3B%20Why%20does%20the%20%26lt%3B%26gt%3B%20work%20with%20an%20array%3F%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EAnyone%20know%20the%20answer%20to%20this%3F%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1059996%22%20slang%3D%22en-US%22%3ERe%3A%20best%20way%20to%20find%20max%20and%20average%20values%20for%20data%20that%20meets%20certain%20criteria%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1059996%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F521%22%20target%3D%22_blank%22%3E%40Sergei%20Baklan%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EYour%20methods%20work.%20I%20ended%20up%20going%3A%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3DMAX(--ISNUMBER(MATCH(data!%24C%241%3A%24N%241%2C%24M%241%3A%24P%241%2C0))*INDEX(data!%24C%242%3A%24N%2413%2CMATCH(%24A2%2Cdata!%24B%242%3A%24B%2413%2C0)%2C0)%2C1)%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3DMAX(--NOT(ISNUMBER(MATCH(data!%24C%241%3A%24N%241%2C%24M%241%3A%24P%241%2C0)))*INDEX(data!%24C%242%3A%24N%2413%2CMATCH(%24A2%2Cdata!%24B%242%3A%24B%2413%2C0)%2C0)%2C1)%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EFor%20the%20max%20of%20sales%20and%20not%20sales%20respectively.%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EWhat%20I%20do%20not%20understand%20is%20why%20if%20I%20try%20to%20do%20the%20same%20thing%20for%20average%3A%26nbsp%3B%3C%2FP%3E%3CP%3E%3DAVERAGE(--ISNUMBER(MATCH(data!%24C%241%3A%24N%241%2C%24M%241%3A%24P%241%2C0))*INDEX(data!%24C%242%3A%24N%2413%2CMATCH(%24A2%2Cdata!%24B%242%3A%24B%2413%2C0)%2C0)%2C1)%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EIt%20doesn't%20work.%26nbsp%3B%20Why%20doesn't%20it%3F%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1059997%22%20slang%3D%22en-US%22%3ERe%3A%20best%20way%20to%20find%20max%20and%20average%20values%20for%20data%20that%20meets%20certain%20criteria%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1059997%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F280482%22%20target%3D%22_blank%22%3E%40Twifoo%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThis%20does%20work.%20It%20seems%20there%20should%20be%20a%20shorter%20way%20to%20do%20it.%20Is%20the%20issue%20dealing%20with%20Arrays%20or%20why%20doesn't%20the%20Average%20or%20averageif%20work%20here%3F%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1060002%22%20slang%3D%22en-US%22%3ERe%3A%20best%20way%20to%20find%20max%20and%20average%20values%20for%20data%20that%20meets%20certain%20criteria%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1060002%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F521%22%20target%3D%22_blank%22%3E%40Sergei%20Baklan%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20don't%20know%20if%20you%20know%20this%20or%20not.%20Why%20does%20aggregate%20work%20with%20Large%20but%20not%20max%2C%20average%20or%20count.%20I%20know%20the%20difference%20between%20Large(%2C)%20and%20Max()%20bit%20it%20doesn't%20see%20like%20that%20should%20be%20applying%20here.%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1060019%22%20slang%3D%22en-US%22%3ERe%3A%20best%20way%20to%20find%20max%20and%20average%20values%20for%20data%20that%20meets%20certain%20criteria%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1060019%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F92549%22%20target%3D%22_blank%22%3E%40Jay%20Lea%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EI%20guess%20with%20MAX()%20instead%20of%20AGGREGATE()%20you%20use%20array%20formula%20which%20is%20not%20needed%20in%20latest%20case.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EAVERAGE()%20doesn't%20work%20since%20using%20ISNUMBER()%20you%20add%20to%20the%20array%20zeroes%20for%20the%20values%20where%20condition%20is%20not%20met%20(in%20addition%20to%20zero%20sales)%20and%20average%20with%20these%20zeroes.%20Plus%26nbsp%3B%20%3CSTRONG%3E%2C1%3C%2FSTRONG%3E%20at%20the%20end%20of%20the%20formula%20is%20not%20needed.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1060030%22%20slang%3D%22en-US%22%3ERe%3A%20best%20way%20to%20find%20max%20and%20average%20values%20for%20data%20that%20meets%20certain%20criteria%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1060030%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F92549%22%20target%3D%22_blank%22%3E%40Jay%20Lea%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EAGGREGATE()%20works%20with%20array%20formulas%26nbsp%3B%20as%20references%20starting%20from%20function%20%2314%20(Large)%20and%20next%20one.%20Previous%20functions%20work%20with%20arrays%20themselves.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1060048%22%20slang%3D%22en-US%22%3ERe%3A%20best%20way%20to%20find%20max%20and%20average%20values%20for%20data%20that%20meets%20certain%20criteria%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1060048%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F521%22%20target%3D%22_blank%22%3E%40Sergei%20Baklan%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ESo%20I%20need%20an%20ifzero()function%20instead%20and%20isnumber().%26nbsp%3B%20What%20is%20the%201%20at%20the%20end%20of%20the%20Max%20relating%20to%3F%20The%20--NOT%3F%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1060100%22%20slang%3D%22en-US%22%3ERe%3A%20best%20way%20to%20find%20max%20and%20average%20values%20for%20data%20that%20meets%20certain%20criteria%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1060100%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F521%22%20target%3D%22_blank%22%3E%40Sergei%20Baklan%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20go%20an%20try%20this%20on%20my%20real%20data%20and%20I%20am%20getting%20an%20error%20with%20the%20Max%20for%20both.%20I%20get%20a%20%23VALUE%20error.%20I%20copied%20a%20large%20subset%20over%20to%20test%20spreadsheet%20and%20I%20am%20getting%20the%20same%20results.%20I%20tried%20to%20trouble%20shoot%20this%20and%20I%20am%20not%20seeing%20it.%26nbsp%3B%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EDo%20you%20(or%20anyone%20else)%20see%20what%20I%20am%20missing%3F%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1060108%22%20slang%3D%22en-US%22%3ERe%3A%20best%20way%20to%20find%20max%20and%20average%20values%20for%20data%20that%20meets%20certain%20criteria%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1060108%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F92549%22%20target%3D%22_blank%22%3E%40Jay%20Lea%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EExtra%201%20in%20this%20your%20formula%3C%2FP%3E%0A%3CP%3E%3CSPAN%3E%3DAVERAGE(--ISNUMBER(MATCH(data!%24C%241%3A%24N%241%2C%24M%241%3A%24P%241%2C0))*INDEX(data!%24C%242%3A%24N%2413%2CMATCH(%24A2%2Cdata!%24B%242%3A%24B%2413%2C0)%2C0)%3CFONT%20color%3D%22%23FF0000%22%3E%3CSTRONG%3E%2C1%3C%2FSTRONG%3E%3C%2FFONT%3E)%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%3EIFZERO()%20doesn't%20exists%20and%20in%20any%20case%20doesn't%20help%20-%20you%20will%20remove%20from%20calculations%20days%20with%20zero%20sales.%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%3EMATCH()%20returns%20an%20array%20positions%20where%20one%20array%20with%20dates%20met%20another%20one%2C%20and%20errors%20(%23N%2FA)%20otherwise.%20ISNUMBER()%20converts%20errors%20to%20zero%20and%20found%20positions%20to%201.%3C%2FSPAN%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1060794%22%20slang%3D%22en-US%22%3ERe%3A%20best%20way%20to%20find%20max%20and%20average%20values%20for%20data%20that%20meets%20certain%20criteria%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1060794%22%20slang%3D%22en-US%22%3EBy%20admitting%20that%20my%20recommended%20formulas%20return%20your%20expected%20results%2C%20you%20must%20be%20contented%20thereby.%20Nonetheless%2C%20I%20admire%20your%20quest%20for%20a%20shorter%20formula%20but%20I%20deem%20my%20recommendation%20as%20heretofore%20the%20shortest!%3CBR%20%2F%3EThe%20group%20of%20AVERAGE%2FIF%2FS%20cannot%20process%20array%20formulas!%20The%20most%20powerful%20among%20their%20%E2%80%9Crelatives%E2%80%9D%20is%20the%20elegant%20COUNTIF%2C%20as%20you%20can%20prove%20in%20the%20file%20I%20attached%20earlier.%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1061676%22%20slang%3D%22en-US%22%3ERe%3A%20best%20way%20to%20find%20max%20and%20average%20values%20for%20data%20that%20meets%20certain%20criteria%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1061676%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F521%22%20target%3D%22_blank%22%3E%40Sergei%20Baklan%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ETwo%20hopefully%20final%20questions.%26nbsp%3B%3C%2FP%3E%3CP%3E1)%20Do%20I%20have%20an%20extra%201%20on%20the%20max%20formulas%3F%26nbsp%3B%3C%2FP%3E%3CP%3E%3DMAX(--ISNUMBER(MATCH(data!%24C%241%3A%24N%241%2C%24M%241%3A%24P%241%2C0))*INDEX(data!%24C%242%3A%24N%2413%2CMATCH(%24A2%2Cdata!%24B%242%3A%24B%2413%2C0)%2C0)%2C%3CFONT%20color%3D%22%23FF0000%22%3E1%3C%2FFONT%3E)%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3DMAX(--NOT(ISNUMBER(MATCH(data!%24C%241%3A%24N%241%2C%24M%241%3A%24P%241%2C0)))*INDEX(data!%24C%242%3A%24N%2413%2CMATCH(%24A2%2Cdata!%24B%242%3A%24B%2413%2C0)%2C0)%2C%3CFONT%20color%3D%22%23FF0000%22%3E1%3C%2FFONT%3E)%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EOr%20do%20I%20need%20that%20one%20for%20Max%3F%20I%20am%20confused%20on%20the%20difference%20as%20that%20was%20working%20with%20sample%20data.%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E2)%20I%20attached%20a%20the%20spreadsheet%20now%20with%20some%20of%20my%20real%20data.%20I%20am%20not%20getting%20a%20%23Value%20Error.%26nbsp%3B%20Do%20you%20see%20why%3F%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThank%20you%20for%20all%20of%20your%20help!!%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1061747%22%20slang%3D%22en-US%22%3ERe%3A%20best%20way%20to%20find%20max%20and%20average%20values%20for%20data%20that%20meets%20certain%20criteria%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1061747%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F92549%22%20target%3D%22_blank%22%3E%40Jay%20Lea%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThat%20extra%201%20was%20being%20considered%20as%20a%20number2%20in%20the%20outer%20Max%20formula%20which%20I%20don't%20think%20is%20required.%3C%2FP%3E%3CP%3EThe%20existing%20formula%20is%20producing%20the%20%23Value!%20error%20because%20you%20cannot%20multiply%20a%20null%20string%20with%20a%20number.%20Wrap%20the%20internal%20calculation%20within%20IFERROR%20to%20handle%20that%20like%20below...%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EIn%20B2%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-markup%22%3E%3CCODE%3E%3DMAX(IFERROR((--ISNUMBER(MATCH(data!%24C%241%3A%24CF%241%2C%24H%241%3A%24S%241%2C0)))*INDEX(data!%24C%242%3A%24CF%2465%2CMATCH(%24A2%2Cdata!%24B%242%3A%24B%2465%2C0)%2C0)%2C0))%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3EIn%20C2%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-markup%22%3E%3CCODE%3E%3DMAX(IFERROR((--NOT(ISNUMBER(MATCH(data!%24C%241%3A%24CF%241%2C%24H%241%3A%24S%241%2C0))))*INDEX(data!%24C%242%3A%24CF%2465%2CMATCH(%24A2%2Cdata!%24B%242%3A%24B%2465%2C0)%2C0)%2C0))%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3EBoth%20the%20formulas%20should%20be%20entered%20as%20Array%20Formulas.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1061811%22%20slang%3D%22en-US%22%3ERe%3A%20best%20way%20to%20find%20max%20and%20average%20values%20for%20data%20that%20meets%20certain%20criteria%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1061811%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F394231%22%20target%3D%22_blank%22%3E%40Subodh_Tiwari_sktneer%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThank%20you!!%20That%20worked%20perfectly.%20I%20think%20I%20am%20having%20the%20same%20issue%20with%20the%26nbsp%3B%3CSPAN%3E%26nbsp%3BCOUNTIF%20to%20find%20average%2C%20but%20I%20can't%20figure%20out%20where%20the%20IFERROR%20go.%20Any%20Advice%3F%26nbsp%3B%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSPAN%3EThanks%20again%20%3C%2FSPAN%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1061881%22%20slang%3D%22en-US%22%3ERe%3A%20best%20way%20to%20find%20max%20and%20average%20values%20for%20data%20that%20meets%20certain%20criteria%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1061881%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F92549%22%20target%3D%22_blank%22%3E%40Jay%20Lea%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3ELike%20this...%3C%2FP%3E%3CP%3EIn%20D2%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-markup%22%3E%3CCODE%3E%3DSUMPRODUCT(IFERROR((COUNTIF(%24G%241%3A%24S%241%2Cdata!%24C%241%3A%24CF%241)*%0AINDEX(data!%24C%242%3A%24CF%2465%2CMATCH(%24A2%2Cdata!%24B%242%3A%24B%2465%2C0)%2C0))%2F%0ASUMPRODUCT(COUNTIF(%24G%241%3A%24S%241%2Cdata!%24C%241%3A%24CF%241*%0A(INDEX(data!%24C%242%3A%24CF%2465%2CMATCH(%24A2%2Cdata!%24B%242%3A%24B%2465%2C0)%2C0)%26lt%3B%26gt%3B%22%22)))%2C0))%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3EIn%20E2%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-markup%22%3E%3CCODE%3E%3DSUMPRODUCT(IFERROR((COUNTIF(%24G%241%3A%24S%241%2Cdata!%24C%241%3A%24CF%241)*%0AINDEX(data!%24C%242%3A%24CF%2465%2CMATCH(%24A2%2Cdata!%24B%242%3A%24B%2465%2C0)%2C0))%2F%0ASUMPRODUCT(COUNTIF(%24G%241%3A%24S%241%2Cdata!%24C%241%3A%24CF%241*%0A(INDEX(data!%24C%242%3A%24CF%2465%2CMATCH(%24A2%2Cdata!%24B%242%3A%24B%2465%2C0)%2C0)%26lt%3B%26gt%3B%22%22)))%2C0))%3C%2FCODE%3E%3C%2FPRE%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1062531%22%20slang%3D%22en-US%22%3ERe%3A%20best%20way%20to%20find%20max%20and%20average%20values%20for%20data%20that%20meets%20certain%20criteria%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1062531%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F394231%22%20target%3D%22_blank%22%3E%40Subodh_Tiwari_sktneer%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EE2%20had%20to%20be%3A%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3DSUMPRODUCT(IFERROR((COUNTIF(%24H%241%3A%24S%241%2Cdata!%24C%241%3A%24CF%241)%3D0)*%3CBR%20%2F%3EINDEX(data!%24C%242%3A%24CF%2465%2CMATCH(%24A2%2Cdata!%24B%242%3A%24B%2465%2C0)%2C0)%2C0)%2F%3CBR%20%2F%3ESUMPRODUCT((COUNTIF(%24H%241%3A%24S%241%2Cdata!%24C%241%3A%24CF%241)%3D0)*%3CBR%20%2F%3E(INDEX(data!%24C%242%3A%24CF%2465%2CMATCH(%24A2%2Cdata!%24B%242%3A%24B%2465%2C0)%2C0)%26lt%3B%26gt%3B%22%22)))%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20got%20it%20to%20work!!!%20Thank%20you%20everyone%20for%20all%20of%20the%20help!!%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1065792%22%20slang%3D%22en-US%22%3ERe%3A%20best%20way%20to%20find%20max%20and%20average%20values%20for%20data%20that%20meets%20certain%20criteria%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1065792%22%20slang%3D%22en-US%22%3EI%E2%80%99m%20glad%20you%20did!%20Nonetheless%2C%20I%20aver%20that%20my%20recommended%20formulas%20were%20crucial.%20Clearly%2C%20what%20you%20claim%20to%20have%20done%20actually%20came%20from%20my%20recommended%20formulas!%20I%E2%80%99m%20just%20sad%20you%20didn%E2%80%99t%20accord%20me%20any%20recognition%20for%20that.%20Worse%2C%20you%20simply%20ignored%20my%20explanation%20to%20your%20queries.%20Hopefully%2C%20you%20realize%20your%20sheer%20inadvertence%2C%20honest%20mistake%2C%20or%20excusable%20negligence%2C%20any%20of%20which%20I%20hereby%20expressly%20condone.%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1066183%22%20slang%3D%22en-US%22%3ERe%3A%20best%20way%20to%20find%20max%20and%20average%20values%20for%20data%20that%20meets%20certain%20criteria%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1066183%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F280482%22%20target%3D%22_blank%22%3E%40Twifoo%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EMy%20greatest%20apologies...%26nbsp%3B%20you%20deserve%20all%20the%20credit%20for%20the%20most%20efficient%20and%20best%20way%20to%20find%20the%20averages.%20It%20was%20an%20oversight%20on%20my%20part.%20Thank%20you%20for%20all%20of%20your%20help.%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E
Occasional Contributor

I have a table with names in column B and dates in row 1. The rest of the tables is the sales amount for the employee listed in column B on the date in row 1.

 

I want to find the max and the average for certain days. For example we have 12 sales on various days a quarter. I want to be able to find the max sales amount on days days that we had sales, and the days we didn't have sales as well as the averages sales amount on the days we had sales and the days we didn't have sales.

 

I can find the row that the data is in using match: =MATCH(A2,data!B:B,0) I can find the if is a sale using max and maxifs in an arrary: {=MAX(MAXIFS(data!$C2:$N2,data!$C$1:$N$1,report!$M$1:$P$1))} or using =AGGREGATE(14,4,MAXIFS(data!$C2:$N2,data!$C$1:$N$1,report!$M$1:$P$1),1)

There is a problem with finding the max if it is not a sale. I am not sure why. I tried: =AGGREGATE(14,4,MAXIFS(data!$C2:$N2,data!$C$1:$N$1,"<>"&report!$M$1:$P$1),1) & {=MAX(MAXIFS(data!$C2:$N2,data!$C$1:$N$1,"<>"&report!$M$1:$P$1))}

I can find the average if it is a sale if there is data for every day, but not if there is data missing. Then I get a #DIV/0 error.

 

Any ideas on this? 

20 Replies

@Jay Lea 

You may try this...

 

In C2

=MAX(MAXIFS(INDEX(data!$C$2:$N$13,MATCH($A2,data!$B$2:$B$13,0),),data!$C$1:$N$1,report!$M$1:$P$1))

 

In D2

=MAX(MAXIFS(INDEX(data!$C$2:$N$13,MATCH($A2,data!$B$2:$B$13,0),),data!$C$1:$N$1,"<>"&report!$M$1:$P$1))

@Jay Lea 

As variant

Max If Sale

=AGGREGATE(14,6,1/--ISNUMBER(MATCH(data!$C$1:$N$1,$M$1:$P$1,0))*INDEX(data!$C$2:$N$13,MATCH($A2,data!$B$2:$B$13,0),0),1)

Max If Not Sale

=AGGREGATE(14,6,1/--NOT(ISNUMBER(MATCH(data!$C$1:$N$1,$M$1:$P$1,0)))*INDEX(data!$C$2:$N$13,MATCH($A2,data!$B$2:$B$13,0),0),1)

Average if sale

=SUMPRODUCT(ISNUMBER(MATCH(data!$C$1:$N$1,$M$1:$P$1,0))*INDEX(data!$C$2:$N$13,MATCH($A2,data!$B$2:$B$13,0),0))/SUMPRODUCT(ISNUMBER(MATCH(data!$C$1:$N$1,$M$1:$P$1,0))*(INDEX(data!$C$2:$N$13,MATCH($A2,data!$B$2:$B$13,0),0)<>0))

Average if Not Sale

=SUMPRODUCT(NOT(ISNUMBER(MATCH(data!$C$1:$N$1,$M$1:$P$1,0)))*INDEX(data!$C$2:$N$13,MATCH($A2,data!$B$2:$B$13,0),0))/SUMPRODUCT(--NOT(ISNUMBER(MATCH(data!$C$1:$N$1,$M$1:$P$1,0)))*(INDEX(data!$C$2:$N$13,MATCH($A2,data!$B$2:$B$13,0),0)<>0))

@Jay Lea 

If your definition of best is "the shortest", I will recommend this formula in C2, as shown in the snapshot below: 

clipboard_image_0.png

Delving into the attached file, you'll see this formula in G2: 

=SUMPRODUCT(COUNTIF($M$1:$P$1,data!$C$1:$N$1)*
INDEX(data!$C$2:$N$13,MATCH($A2,data!$B$2:$B$13,0),0))/
SUMPRODUCT(COUNTIF($M$1:$P$1,data!$C$1:$N$1*
(INDEX(data!$C$2:$N$13,MATCH($A2,data!$B$2:$B$13,0),0)<>"")))

Note that I used the elegant COUNTIF instead of the familiar ISNUMBER-MATCH combination.

@Subodh_Tiwari_sktneer 

 

The one for C2 worked perfectly, but the one for D2 did not. The "<>"& doesn't give an error but it doesn't seem to be working.   You are doing it they way I wanted to do it. I wasn't sure how to do an index match with maxifs, but it is working.  Why does the <> work with an array? 

 

Anyone know the answer to this? 

 

 

@Sergei Baklan 

 

Your methods work. I ended up going: 

 

=MAX(--ISNUMBER(MATCH(data!$C$1:$N$1,$M$1:$P$1,0))*INDEX(data!$C$2:$N$13,MATCH($A2,data!$B$2:$B$13,0),0),1)

 

=MAX(--NOT(ISNUMBER(MATCH(data!$C$1:$N$1,$M$1:$P$1,0)))*INDEX(data!$C$2:$N$13,MATCH($A2,data!$B$2:$B$13,0),0),1)

 

For the max of sales and not sales respectively. 

 

What I do not understand is why if I try to do the same thing for average: 

=AVERAGE(--ISNUMBER(MATCH(data!$C$1:$N$1,$M$1:$P$1,0))*INDEX(data!$C$2:$N$13,MATCH($A2,data!$B$2:$B$13,0),0),1)

 

It doesn't work.  Why doesn't it? 

 

@Twifoo 

 

This does work. It seems there should be a shorter way to do it. Is the issue dealing with Arrays or why doesn't the Average or averageif work here? 

@Sergei Baklan 

 

I don't know if you know this or not. Why does aggregate work with Large but not max, average or count. I know the difference between Large(,) and Max() bit it doesn't see like that should be applying here. 

@Jay Lea 

I guess with MAX() instead of AGGREGATE() you use array formula which is not needed in latest case.

 

AVERAGE() doesn't work since using ISNUMBER() you add to the array zeroes for the values where condition is not met (in addition to zero sales) and average with these zeroes. Plus  ,1 at the end of the formula is not needed.

@Jay Lea 

AGGREGATE() works with array formulas  as references starting from function #14 (Large) and next one. Previous functions work with arrays themselves.

@Sergei Baklan 

 

So I need an ifzero()function instead and isnumber().  What is the 1 at the end of the Max relating to? The --NOT? 

 

 

@Sergei Baklan 

 

I go an try this on my real data and I am getting an error with the Max for both. I get a #VALUE error. I copied a large subset over to test spreadsheet and I am getting the same results. I tried to trouble shoot this and I am not seeing it.  

 

Do you (or anyone else) see what I am missing? 

@Jay Lea 

Extra 1 in this your formula

=AVERAGE(--ISNUMBER(MATCH(data!$C$1:$N$1,$M$1:$P$1,0))*INDEX(data!$C$2:$N$13,MATCH($A2,data!$B$2:$B$13,0),0),1)

 

IFZERO() doesn't exists and in any case doesn't help - you will remove from calculations days with zero sales.

 

MATCH() returns an array positions where one array with dates met another one, and errors (#N/A) otherwise. ISNUMBER() converts errors to zero and found positions to 1.

By admitting that my recommended formulas return your expected results, you must be contented thereby. Nonetheless, I admire your quest for a shorter formula but I deem my recommendation as heretofore the shortest!
The group of AVERAGE/IF/S cannot process array formulas! The most powerful among their “relatives” is the elegant COUNTIF, as you can prove in the file I attached earlier.

@Sergei Baklan 

 

Two hopefully final questions. 

1) Do I have an extra 1 on the max formulas? 

=MAX(--ISNUMBER(MATCH(data!$C$1:$N$1,$M$1:$P$1,0))*INDEX(data!$C$2:$N$13,MATCH($A2,data!$B$2:$B$13,0),0),1)

 

=MAX(--NOT(ISNUMBER(MATCH(data!$C$1:$N$1,$M$1:$P$1,0)))*INDEX(data!$C$2:$N$13,MATCH($A2,data!$B$2:$B$13,0),0),1)

 

Or do I need that one for Max? I am confused on the difference as that was working with sample data. 

 

2) I attached a the spreadsheet now with some of my real data. I am not getting a #Value Error.  Do you see why? 

 

Thank you for all of your help!! 

@Jay Lea 

That extra 1 was being considered as a number2 in the outer Max formula which I don't think is required.

The existing formula is producing the #Value! error because you cannot multiply a null string with a number. Wrap the internal calculation within IFERROR to handle that like below...

 

In B2

=MAX(IFERROR((--ISNUMBER(MATCH(data!$C$1:$CF$1,$H$1:$S$1,0)))*INDEX(data!$C$2:$CF$65,MATCH($A2,data!$B$2:$B$65,0),0),0))

In C2

=MAX(IFERROR((--NOT(ISNUMBER(MATCH(data!$C$1:$CF$1,$H$1:$S$1,0))))*INDEX(data!$C$2:$CF$65,MATCH($A2,data!$B$2:$B$65,0),0),0))

Both the formulas should be entered as Array Formulas.

 

 

@Subodh_Tiwari_sktneer 

 

Thank you!! That worked perfectly. I think I am having the same issue with the  COUNTIF to find average, but I can't figure out where the IFERROR go. Any Advice? 

 

Thanks again

@Jay Lea 

Like this...

In D2

=SUMPRODUCT(IFERROR((COUNTIF($G$1:$S$1,data!$C$1:$CF$1)*
INDEX(data!$C$2:$CF$65,MATCH($A2,data!$B$2:$B$65,0),0))/
SUMPRODUCT(COUNTIF($G$1:$S$1,data!$C$1:$CF$1*
(INDEX(data!$C$2:$CF$65,MATCH($A2,data!$B$2:$B$65,0),0)<>""))),0))

In E2

=SUMPRODUCT(IFERROR((COUNTIF($G$1:$S$1,data!$C$1:$CF$1)*
INDEX(data!$C$2:$CF$65,MATCH($A2,data!$B$2:$B$65,0),0))/
SUMPRODUCT(COUNTIF($G$1:$S$1,data!$C$1:$CF$1*
(INDEX(data!$C$2:$CF$65,MATCH($A2,data!$B$2:$B$65,0),0)<>""))),0))
Best Response confirmed by Jay Lea (Occasional Contributor)
Solution

@Subodh_Tiwari_sktneer 

 

E2 had to be: 

 

=SUMPRODUCT(IFERROR((COUNTIF($H$1:$S$1,data!$C$1:$CF$1)=0)*
INDEX(data!$C$2:$CF$65,MATCH($A2,data!$B$2:$B$65,0),0),0)/
SUMPRODUCT((COUNTIF($H$1:$S$1,data!$C$1:$CF$1)=0)*
(INDEX(data!$C$2:$CF$65,MATCH($A2,data!$B$2:$B$65,0),0)<>"")))

 

I got it to work!!! Thank you everyone for all of the help!! 

I’m glad you did! Nonetheless, I aver that my recommended formulas were crucial. Clearly, what you claim to have done actually came from my recommended formulas! I’m just sad you didn’t accord me any recognition for that. Worse, you simply ignored my explanation to your queries. Hopefully, you realize your sheer inadvertence, honest mistake, or excusable negligence, any of which I hereby expressly condone.