Search code examples
google-sheetsgoogle-query-language

Sum of a required value within two separate date range using Query function in Google sheet


I am in need of a sum of a completed values present in between two separate dates using Query function. My sheets are as follows. The first sheet name is "Sheet1" & The 2nd sheet name is "Sheet2". I need the count(SUM) of India completed values in the cell Sheet2!A2 within the date range of Cell A1 & Cell A2. For this, I was trying with the below Query function. But it didn't work out. Can anyone please help me here to get this data.

Sheet1

enter image description here


Solution

  • You need to use the below formula there

     =sum(query(Sheet1!$A$1:$D$13,"Select 1 where D='India' and A>=date '" & TEXT(A1,"yyyy-mm-dd") & "' and A<= date '" & TEXT(B1,"yyyy-mm-dd") &"'",1),0)