Excel - Counting unique values that meet multiple criteria -
i'm trying use function count number of unique cells in spreadsheet that, @ same time, meet multiple criteria.
given following example:
a b c quant store# product 1 75012 banana 5 orange 6 56089 orange 3 89247 orange 7 45321 orange 2 apple 4 45321 apple
in example above, need know how many unique stores valid store# have received oranges or apples. in case above, result should 3 (stores 56089, 89247 , 45321).
this how started try solving problem:
=sum(if(frequency(b2:b9,b2:b9)>0,1))
the above formula yield number of unique stores valid store#, not ones have received oranges or apples. how can add criteria?
mine done different way (and works), main reason posting because wondering if second part of formula somehow made array formula making shorter.
to this, sort 3 columns on column b smallest largest , since part of array formula, type in formula , [ctrl]+[shift]+[enter]. sorted data looks this:
b c quant store# product 7 45321 orange 4 45321 apple 6 56089 orange 1 75012 banana 3 89247 orange 5 orange 2 apple
and formula is:
={sum((b3:b9>0)*(c3:c9="orange"))+sum((b3:b9>0)*(c3:c9="apple"))}-{if(and(or(c3="orange",c3="apple"),or(c4="orange",c4="apple"),b3=b4),1,0)+if(and(or(c4="orange",c4="apple"),or(c5="orange",c5="apple"),b4=b5),1,0)+if(and(or(c5="orange",c5="apple"),or(c6="orange",c6="apple"),b5=b6),1,0)+if(and(or(c6="orange",c6="apple"),or(c7="orange",c7="apple"),b6=b7),1,0)}
the first part (in curly braces) pretty self-explanatory:
sum((b3:b9>0)*(c3:c9="orange"))+sum((b3:b9>0)*(c3:c9="apple"))
what interested in trying see if second part can expressed array formula. had come with
=sum((and((c3:c9="orange"),or(c4:c9="orange",c4:c9="apple")))*(b3:b9=b4:b10)*(b3:b9<>""))
but seems counting "banana" legit entry reason. therefore, had go entering elements in 2nd part manually rather use array formula. have ideas how done?
Comments
Post a Comment