I have the following query that is functioning fine. However at there will be results for example a future date where the query will not have results "Query completed with an empty output.". I'd like to replace the #N/A with 0 if possible.
Thank you in advance.
Sample Sheet
https://docs.google.com/spreadsheets/d/1GvH5Nyeg447_STTMgYj9VeLdwo7Mi2TnIWodbJOX3zw/edit#gid=0
=Query('Balance History'!B:O,"Select H WHERE G = '"&E2&"' and M = '"&B2&"' and N = '"&C2&"' ORDER BY O DESC Limit 1",0)
Try
=IFERROR(Query('Balance History'!B:O,"Select H WHERE G = '"&E2&"' and M = '"&B2&"' and N = '"&C2&"' ORDER BY O DESC Limit 1",0),0)
Related
I have a Google spreadsheet with a tab called 'Updates'. In a separate tab, I want to use drop-down menus (contained in cells B3, B4 and B5 in the code below) to filter and subsequently view the data in the 'Updates' tab according to its text in columns B, C and D.
I have written the following code. Basically I want to be able to filter the data according to selections made in all 3 drop down menus (B3, B4 and B5), or just in two of them (e.g. B3 and B4, but B5 is left blank), or just in one of them (e.g. B3, and B4 and B5 are left blank).
=query(Updates!A1:E, " select * (where B = '"&B3&"' AND C = '"&B4&"' AND D = '"&B5&"') OR (where B = '"&B3&"' OR C = '"&B4&"' OR D = '"&B5&"') OR (where (B = '"&B3&"' OR C = '"&B4&"') AND D = '"&B5&"') OR (where B = '"&B3&"' AND (C = '"&B4&"' OR D = '"&B5&"') ) OR (where C = '"&B4&"' AND (B = '"&B3&"' OR D = '"&B5&"') ")
The AND and OR functions work separately in their own query functions, but when I combine them together I get the following error message:
Error
Unable to parse query string for Function QUERY parameter 2: PARSE_ERROR: Encountered " "(" "( "" at line 1, column 11. Was expecting one of: "where" ... "group" ... "pivot" ... "order" ... "skipping" ... "limit" ... "offset" ... "label" ... "format" ... "options" ...
Any help? Thanks!
you can use where only once in one QUERY. try:
=QUERY(Updates!A1:E,
"where 9=9 "&
IF(B3="",," and B = '"&B3&"'")&
IF(B4="",," and C = '"&B4&"'")&
IF(B5="",," and D = '"&B5&"'"), )
I'm trying to show only the first result from column (G) of the output of this query:
=QUERY(data!A1:O7122; "SELECT G, COUNT(G) WHERE E = '"&A3&"' GROUP BY G LABEL G '', COUNT(G) ''";0)
So I tried this:
=INDEX(QUERY(data!A1:O7122; "SELECT G, COUNT(G) WHERE E = '"&A3&"' GROUP BY G LABEL G '', COUNT(G) ''";0), 1, 1)
But it doesn't work (error). Any idea...? :)
I can display your expected output with slight adjustment on your formula as following, although I do not use your raw data for calculation:
=index(QUERY(data!A1:O18, "SELECT G, Count(G) WHERE E = '"&A1&"' Group By G Order by Count(G) Desc Label Count(G) ''",0),1,1)
Comparison without index as following:
I'm trying to filter out a set of data within a specific hour here's my formula:
Column D is the actual day and D is the time of the day (Column C)
=QUERY('RD'!A3:W,"SELECT F,H,O,Q WHERE G = '"&$F$3&"' AND C = Date '"&TEXT($C$35,"yyyy-mm-dd")&"' AND (D >= TIME '"&TEXT(F35,"HH:mm:ss")&"' AND D < TIME '"&TEXT(G35,"HH:mm:ss")&"')")
data
formula
try:
=QUERY('RD'!A3:W,
"select F,H,O,Q
where G = '"&$F$3&"'
and C = date '"&TEXT($C$35, "yyyy-mm-dd")&"'
and D >= timeofday '"&TEXT(F35, "HH:mm:ss")&"'
and D < timeofday '"&TEXT(G35, "HH:mm:ss")&"'")
see: https://developers.google.com/chart/interactive/docs/querylanguage
I have the following query which is working just fine.
but now I want to take the returned value in A which is a unique number and hyperlink it.
The resulting display should be just the number. The URL for the link is fixed with the number appended at the end e.g.
number = 123456
URL = https:\google.com\123456
my current query is:
=iferror(
if(C2="Closed",
QUERY(DATA!A:AA, "
SELECT A,B, D, T, N
WHERE( AA CONTAINS '" & lower(C1) & "' AND L = " & J1 & ")
Order by T Asc"),
QUERY(DATA!A:AA, "
SELECT A,B, D, R, N
WHERE( AA CONTAINS '" & lower(C1) & "' AND L = " & J1 & ")
Order by T Asc")
)
how can I manipulate the results of the query so each line returned the value in A is hyperlinked?
B8: =QUERY(B2:E5, "select C where E contains 'h11'", 0)
B14: =ARRAYFORMULA("www.abc.com/"&QUERY(B2:E5, "select C where E contains 'h11'", 0))
When given the choice to either join or filter in Pig, which is more performance-intensive?
Joins are always costly as you have to scan through second table for each tuple in table one. Consider below example
A = LOAD 'data1' AS (a1:int,a2:int,a3:int);
DUMP A;
(1,2,3)
(4,2,1)
(8,3,4)
(4,3,3)
(7,2,5)
(8,4,3)
B = LOAD 'data2' AS (b1:int,b2:int);
DUMP B;
(2,4)
(8,9)
(1,3)
(2,7)
(2,9)
(4,6)
(4,9)
X = JOIN A BY a1, B BY b1;
DUMP X;
(1,2,3,1,3)
(4,2,1,4,6)
(4,3,3,4,6)
(4,2,1,4,9)
(4,3,3,4,9)
(8,3,4,8,9)
(8,4,3,8,9)
When we join in X we traverse through each tuple in B for each tuple in A. For filter we just traverse once through dataset and perform filter operation on each tuple.
X = FILTER A BY a3 == 3;
DUMP X;
(1,2,3)
(4,3,3)
(8,4,3)