I am using the new Google Spreadsheets that was rolled out a couple of weeks back. I'm using a following query to pull data out of another spreadsheet:
=QUERY(IMPORTRANGE("https://docs.google.com/spreadsheet/ccc?key=blablathisisanexample", "samplesheet!A:D"), "select SUM(Col4) where ( Col1 >= date '2012-1-1' ) ")
The query works perfectly well if I remove the bit 'where ( Col1 >= date '2012-1-1' )'. It will pull data and sum it correctly.
But what's wrong with my where-col1-date filter thingy? It's written the way it was in previous version of Google Spreadsheet, and it gives no error messages. It just returns a header and no result, as if it didn't find a single date. The dates in the data file are in column 1, written in format 4/7/2014, for example. This used to work in the previous version and I'm at a loss now.
I have several suggestions here. But first: Let's copy the "2012-1-1" value to a particular cell, say F5, and write it with the exact same date format az in the original spreadsheet: 1/1/2012.
Use FILTER function:
=SUM(FILTER(IMPORTRANGE("https://docs.google.com/spreadsheet/ccc?key=blablathisisanexample", "samplesheet!D:D"), IMPORTRANGE("https://docs.google.com/spreadsheet/ccc?key=blablathisisanexample", "samplesheet!A:A")>=F5))
I admit that it's not that pretty because of the two ImportRange functions, but it works for sure, I tried it.
If you insist on using QUERY then try to replace the where condition as follows:
"select SUM(Col4) where ( Col1 >= " & F5 & ")"
I haven't tried this one, but the first one (with FILTER) should work.
Related
I've got a Spreadsheet where on the sheet "Dados de Cadastro e Resumo" on column K (from roll 7 to 29) I'm using the formula =IF(J7="";"";SUM(QUERY({Caminhoneiro!G:I;Centralizado!G:I;Djoko!G:I};"Select Col2 where Col1 = '"&J7&"'";))) to sum up the hours from the sheets "Caminhoneiro","Djoko" and "Centrealizado".
The thing is, I want to make it so I don't have to edit the formula every time to accommodate for new sheets. My ideia was to use the names on column E (from roll 7 to 29) and make the reference for the Query based on that.
So far I've got the string done (on M6), but haven't been successful on turning that on to a valid array reference (using INDIRECT, which I later learned doesn't deal with multiple intervals.
I have been working on this issue for a few weeks now and can't seem to find a solution. I used this answer (IMPORTRANGE with CONDITIONS) to get as far as I could, but I keep getting a value error.
This is the sheet I'm working with.
My goal is to use the first tab in the sheet (All Games) to enter all the games that I come across to create a compendium. But, then I want it to automatically populate the other tabs based on certain criteria (what type of game, skills learned, etc.)
On the Warm-Ups tab you'll see the formulas I have tried. A1 is the most recent.
Here is the formula I tried:
=QUERY(IMPORTRANGE("https://docs.google.com/spreadsheets/d/1F64PMg_iFu-DaJAUaE4BkpqF4zoteknp56VfwAUe8ag/edit#gid=1359689553", "All Games!A1:A1300"),"SELECT Col1 WHERE (Col2 = 'w') ")
I am getting a value error:
Unable to parse query string for Function QUERY parameter 2: NO_COLUMN: Col2
you are trying to reference Col2 but you selected range A1:A1300 which is just 1 column. therefore try:
=QUERY(IMPORTRANGE("1F64PMg_iFu-DaJAUaE4BkpqF4zoteknp56VfwAUe8ag", "All Games!A1:B1300"),
"SELECT Col1 WHERE (Col2 = 'w') ")
from the brief look on your sheet, you may want use matches or contains instead of = in your QUERY
You are only importing (part of) ColumnA - so no wonder Google can't find a second column :)
I am creating a budget tracker within Google Sheets. I am having trouble with Google Query Language returning results that do not exist in the source data
I have a Google Form into which expenditure can be entered, which populates an associated Sheet in my Google Drive. My Master budget tracker also sits within my Google Drive. I use IMPORTRANGE to pull the data into the Master from the Responses spreadsheet, and then Query to separate this out into different 'expenditure' categories on sheets within the workbook (one for each month). February worked perfectly - all expenditure was found and summed correctly and then the February sheet was duplicated for each month of the year, the formulae or look up terms updated. But March is acting strangely - it is returning a value for March that doesn't exist - and not only does the summed value not exist but the word 'March' also does not exist either, so shouldn't be matching. I have tweaked the code, tried refreshing and rewriting the formula into the cell to force a refresh, re-imported the range from the external spreadsheet, I have tried various parentheses placements (I'm not a SQL or Google Query Language expert, so am feeling my way a bit) as I thought it was something to do with the AND/OR clauses not being 'collated', but none has produced even a different result, it's always the same false value being returned
The query code is as follows:
=query(spend, "select sum(B) where H = '"&$H$1&"' and E='Leisure' or E='Tickets' or E='Parking' or E='Other' label sum(B) ''", -1)
'spend' is the range containing the data imported from the Responses spreadsheet, which includes several post form completion formulae coding the row with a day and a month. Right now, there are only values coded as 'February' in H - nothing else. Cell H1 contains the month name (written in, not formula). This formula works perfectly within the 'February' sheet, and if I update cell H1 to read 'February' in the March sheet it shows the accurate values for February, however, if I enter 'March' in H1 I am getting the odd outcome
I am expecting a £0 result for March, but instead, I am getting a value of £19.46. As previously described - the source list 'spend' only contains values coded as February in H, and the value £19.46 does not appear singularly in the list (and doesn't appear to be made by any values when 'summed'). I am at a loss as to what is happening, and no answers seem to address the appearance of mystery values, so I hope I'm not repeating old ground - please do correct me if I am, and many thanks in advance for any guidance
you picked 19.46 because even if H1 wasn't found in Query, Query continued to evaluate for AND and OR statements and sum up a bunch of nonsense
=IFERROR(IF(QUERY(spend,
"select count(H)
where H='"&$H$1&"'
label count(H)''", 0)>0,
QUERY(spend, "select sum(B)
where (H='"&$H$1&"')
AND (E='Leisure')
OR (E='Tickets')
OR (E='Parking')
OR (E='Other')
label sum(B)''", -1), ), )
I think you might just want to try this:
=query(spend, "select sum(B) where H = '"&$H$1&"' AND (E='Leisure' OR E='Tickets' OR E='Parking' OR E='Other') label sum(B) ''", -1)
EDIT: This will cause an error since it will return an empty query, so try this instead.
=iferror(query(spend, "select sum(B) where H = '"&$H$1&"' AND (E='Leisure' OR E='Tickets' OR E='Parking' OR E='Other') label sum(B) ''", -1),0)
I have a spreadsheet with 1 sheet of software version an another sheet of installation records. I want to do a conditional formatting that compares the version of in installation (on column F) to its know latest version number on another sheet ('Software Versions').
Current Solution
I came up with this formular initially:
=AND(F2<>"", F2=G2)
It works. But I need to maintain a column of QUERY results on G2:
=QUERY('Software Versions'!$A$1:$B$8, "Select B where A='" &D4& "' LIMIT 1")
Problem
Now I want to remove the G2 row altogether. I came up with this combined query:
=AND(F2<>"", F2=QUERY('Software Versions'!$A$1:$B$8, "Select B where A='" &D4& "' LIMIT 1"))
But I cannot save it because it is an "Invalid Formula":
Any way to actually do it?
Try use this formula:
=AND(F2<>"", F2=IFERROR(QUERY(INDIRECT("'Software Versions'!$A$1:$B$8"),
"Select B where A='" &D4& "' LIMIT 1 label B ''"),""))
I was able to make conditional formatting with this formula.
Improvements
Use indirect to address another sheet
Use label B '' to prevent header appear as query result
Use iferror(..., "") to be sure no error occurs when no data is found with query
I'm used to the good old VLOOKUP function for my conditional formattings.
The syntax is VLOOKUP(valueOrCell, sourceRange, index, FALSE)
So if the value from first parameter valueOrCell, exists in the sourceRange, return the value at index. FALSE is to have the exact match.
In my example I'm using only a single worksheet, but if you set the sourceRange to different worksheet it works as well.
I'm trying to combine the data in two sheets into another sheet by using the below code:
=UNIQUE(ArrayFormula(query({filter('Sheet1'!A2:B,NOT(ISBLANK('Sheet1'!A2:A)));filter('Sheet2'!A2:B,NOT(ISBLANK('Sheet2'!A2:A)))},"order by Col1")))
It works perfect if both sheets have at least 1 row filled but if either of the tabs are empty, then I receive #Value.
How can I fix this code so that it still works if either of the tabs are empty?
Filter throws an error instead of returning no values, a property that is very annoying in this case.
Since you're already using the query command why don't you try this, either one or both ranges can be completely empty.
=UNIQUE(ArrayFormula(query(
{Sheet1!A2:B; Sheet2!A2:B},
"WHERE Col1 is not null order by Col1")))
Alternatively if Col1 contains always strings a shorthand is Col1 <> ''