S
S
SkyDelete2021-11-24 22:45:15
Google Sheets
SkyDelete, 2021-11-24 22:45:15

Why does Query in Google Spreadsheets return a string that doesn't match the query?

There is a Google table with product sales data containing 2 sheets, on the Daily Sales sheet in column L I want to substitute the value from column P of the Sales Data page, provided that the initial balance (F) = 0, product ID (A) = A and date(O) = C, I got this query:

QUERY('Sales Data'!A:Q; "Select P where (F=0 and A="&A2&" and O="&C2&")")


But instead of the expected value, the value of 1 row is returned, which does not match any of the conditions.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander Ivanov, 2021-11-25
@SkyDelete

In fact, the formula returns everything correctly - the title of the empty result of its work.
To truncate this header, you need to use the third argument QUERY(;;0)
. Note that if QUERY returns more than one response, then there will be an error. The choice of this formula in these circumstances is unfortunate.
But still, you need to convert the date C2to the desired format=date '"&TEXT(C2;"yyyy-MM-dd")&"'

=IFNA(
  QUERY(
    'Sales Data'!A:Q;
    "Select P where (F=0 and A="&A2&" and O=date '"&TEXT(C2;"yyyy-MM-dd")&"')";
    0
  );
)

619efef8f1487750037542.png

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question