Otterly
Otterly

Reputation: 1

Query returning 1st cell in range although condition is not met (Google Sheets)

I'm a first time query-user, so I'm out of my depth for fixing this myself.

Here's what I have and am looking to accomplish in two separate Google Sheets spreadsheets:

  1. Spreadsheet1 - column A contains a list of names, column B contains a checkbox for true or false
  2. Spreadsheet2 - import list of names from Spreadsheet1 column A where column B is true (and transpose the names so they appear in columns)

This is the formula I'm using in Spreadsheet2:
=TRANSPOSE(QUERY(IMPORTRANGE(LinkToSpreadsheet1,"Sheet1!A39:B51"),"Select Col1 where Col2 = TRUE",1))

The problem I'm facing is:
When column B in Spreadsheet1 contains only FALSE results, the formula is still returning cell A39 as the result, rather than returning no result.

I've also tested that when column B in Spreadsheet1 does contain a TRUE result (for example cell B48 = TRUE), but A39 is FALSE -- it is still returning cell A39 in addition to the matching TRUE cell of A48.

Upvotes: 0

Views: 392

Answers (1)

player0
player0

Reputation: 1

The problem I'm facing is: When column B in Spreadsheet1 contains only FALSE results, the formula is still >returning cell A39 as the result, rather than returning no result.

that's because you use 1 as 3rd query parameter. you should use 0. try:

=IFERROR(TRANSPOSE(QUERY(IMPORTRANGE(LinkToSpreadsheet1,"Sheet1!A39:B51"),
 "select Col1 where Col2 = TRUE", 0)))

Upvotes: 2

Related Questions