Home > Enterprise >  Google Sheet Query Pivot - count if a date is between a range of dates
Google Sheet Query Pivot - count if a date is between a range of dates

Time:04-01

enter image description here


update:

=ARRAYFORMULA(QUERY(QUERY(SPLIT(FLATTEN(IF(DATEDIF(B2:B; C2:C; "Y")>=
 SEQUENCE(1; MAX(DATEDIF(B2:B; C2:C; "Y")); ); ROW(A2:A)&"×"&A2:A&"×"&
 YEAR(B2:B) SEQUENCE(1; MAX(DATEDIF(B2:B; C2:C; "Y")); )&"-1-1"; )); "×"); 
 "select Col2,count(Col2) 
  where year(Col3) matches '2018|2019|2020' 
  group by Col2 
  pivot year(Col3) 
  label Col2'Between'"); 
 "order by Col4 desc, Col3 desc, Col2 desc"))

enter image description here

  • Related