Home > Enterprise >  List unique items, count and sort numerically by descending order, and combine with validate menu fo
List unique items, count and sort numerically by descending order, and combine with validate menu fo

Time:06-17

I need to apply solution found in this question:
enter image description here

My dummy file:
enter image description here

CodePudding user response:

This should do it.

=QUERY(
  A:B,
  "Select B, count(B) 
   where 
    B matches '^(?!(?:ITEMS|ExcludeB|ExcludeC)$). ' and
    A >= date '"&
     TEXT(
      IFERROR(
       VLOOKUP(
        D2,
        {"2 4 H O U R S",TODAY()-1;
         "3  D A Y S",TODAY()-3;
         "7  D A Y S",TODAY()-7;
         "2  W E E K S",TODAY()-14;
         "1  M O N T H",EDATE(TODAY(),-1);
         "3  M O N T H S",EDATE(TODAY(),-3);
         "6  M O N T H S",EDATE(TODAY(),-6);
         "1  Y E A R",EDATE(TODAY(),-12);
         "2  Y E A R S",EDATE(TODAY(),-24);
         "3  Y E A R S",EDATE(TODAY(),-36)},
        2,FALSE),0),"yyyy-mm-dd")&"'
   group by B
   order by 
    count(B) DESC,
    B asc 
   label count(B) ''")
  • Related