Search code examples
pivotgoogle-sheets-formulabetweengoogle-query-language

Google sheets query, group by and pivot between two dates


I really need your help. After hours, I cant figure out, how can I combine these two together:

=QUERY(data!A:L;"select D,  COUNT(D) group by(D) pivot A";1)

=QUERY(data!A:L;"select D WHERE D >= date '"&TEXT(A1;"yyyy-mm-dd")&"' AND  D<= date '"&TEXT(B1;"yyyy-mm-dd")&"'  ";1)

I need the dataset as is visible on the "unfiltered" sheet:
enter image description here
but in between two dates.

This is the dataset:
enter image description here

This is the sheet:
https://docs.google.com/spreadsheets/d/1n6dtmMdbbG4qG7HXYI2vdA3cBDNnbtt1i6a7Cw9gdhA/edit?usp=sharing


Solution

  • This seems to work:

    =QUERY(data!A:L;"select D, COUNT(D) WHERE D >= date '"&text(date(2020;12;1);"yyyy-MM-dd")&"' AND D <= date '"&text(date(2020;12;10);"yyyy-MM-dd")&"' group by(D) pivot A ";1)
    

    I have inputed my own dates date(2020;12;1) and date(2020;12;10), because I don't know where do you have them defined.