Search code examples
validationgoogle-sheetsimportgoogle-sheets-formulaformula

Google Sheets - Import Range issue and building a formula that both Import Ranges but based on corresponding Data Validation in another column


I have a two fold question.

First issue: I have been using the formula answer provided here to importrange, and it works correctly. However making the test spreadsheets for my original question it is not working. All in Google Sheets and saved correctly. What seems to be going wrong? Using COUNTIF + IMPORTRANGE together is the Stack Overflow link where I used the longer formula, third answer.

Real issue: I would like to use this formula, or another to pull a Count of values in one column, with a specific Data Validation answer in another column, into a Master Sheet. For example, in the test spreadsheets linked below, I want to import into Sheet 2, the number of entries from Sheet 1 Column B that have Test 1 in Column A. In another cell of Sheet 2, I want to import the number of entries from Column B that have Test 2 in Column A.

=INDEX(COUNTA(IFNA(QUERY(IFERROR(IMPORTRANGE("URL", "Sheet2!A1:A10")*1), "where Col1 > 0"))))

is the formula that was working for me in my actual work, but now isn't in the test sheets I made. I was also trying to add a qualifier into it for the data validation column, but can't seem to get that to work.

Sheet 1 [where the values are] https://docs.google.com/spreadsheets/d/1W2Rqq3jhp-26LJ5gFNmLSl9kr5Ce4SxVcNF5Z9EiRoc/edit?gid=0#gid=0

Sheet 2 [where I want to import Sheet 1 totals] https://docs.google.com/spreadsheets/d/1n7_qRxslpdWZoC6mpV6HJMmyg7_l8LZPpMwaHBqIjHQ/edit?gid=0#gid=0


Solution

  • You may try:

    =countif(importrange("1W2Rqq3jhp-26LJ5gFNmLSl9kr5Ce4SxVcNF5Z9EiRoc","Sheet 1!A:A"),"Test 1")
    

    enter image description here


    via QUERY()

    =let(data,importrange("1W2Rqq3jhp-26LJ5gFNmLSl9kr5Ce4SxVcNF5Z9EiRoc","Sheet 1!A:A"),
         query(data,"Select count(Col1) Where Col1='Test 1' label count(Col1) ''"))
    

    enter image description here