Search code examples
dategoogle-sheetsimportgoogle-sheets-formulagoogle-query-language

Using importrange with Sumifs in Google Sheets


I am trying to import some data from a very large sheet into another sheet using the sumif function that contains text and dates

The sumif is as follows:

=SUMIFS(H2:H, D2:D, "United States of America", F2:F, ">01/01/2021", F2:F, "<01/01/2022")

This works and returns the correct number

However when I try to combines this with an importrange function it all falls apart

All help greatly accepted


Solution

  • try:

    =QUERY(IMPORTRANGE("id", "sheetname!D:H"), 
     "select sum(Col5) 
      where Col1 = 'Russia' 
        and Col3 > date '2021-01-01'
        and Col3 < date '2022-01-01'
      label sum(Col5)''")