I have an importrange array to get data from alot of sheets. I organise zhem into one list and then make calculations from this list.
WORKBOOK
https://docs.google.com/spreadsheets/d/1OH_LF9r04rRb1ZMuc26CwIq3NQ-qWVlb8mXJwuTechk/edit#gid=28668687
SOURCE WORKBOOK (Tracker)
https://docs.google.com/spreadsheets/d/1huVGusrmhZ60zy9pg59PKN_yfL1XulwvLW5EWwHguvA/edit#gid=2007038591
sheet MODTANEWBIE_QUERY
formula #1 (add UID to DATE):
=IF($B$2="No","",ARRAYFORMULA({MODTANEWBIE_PER!A$3&"#"&QUERY(IMPORTRANGE(MODTANEWBIE_PER!$C$3,"Tracker!"&B$3&":"&B$4&MODTANEWBIE_PER!$D$3),"select Col1 WHERE Col1 = "&A2)}))
formula #2 (get data from specific column in #Tracker based on date)
=IF($B$2="No","",ARRAYFORMULA({QUERY(IMPORTRANGE(MODTANEWBIE_PER!$C$3,"Tracker!"&B$3&":"&B$4&MODTANEWBIE_PER!$D$3),"select Col1 WHERE Col1 = "&A2)}))
For some reason I an unable to query the importrange's Date that corresponds to the cell A2 in _QUERY sheet.
Please am I missing something silly? Is there a format problem?
Thanks alot for any help!
formula should be:
=IF($B$2="No",,ARRAYFORMULA(MODTANEWBIE_PER!A$3&"#"&QUERY(IMPORTRANGE(MODTANEWBIE_PER!$C$3,"Tracker!"&B$3&":"&B$4&MODTANEWBIE_PER!$D$3),"select Col1 WHERE Col2 = date '"&TEXT(A2, "e-m-d")&"'")))
however:
tracker sheet does not contain today's date so A2 needs to be a valid date
dates on tracker sheet are in column B so B4 cant be A
query will then look for where Col2 where dates are
and query is picky on dates if they are not in this format: yyyy-mm-dd
Related
I want to write a query to combine data from two sheets with same heading where data in first column is either a date or a specific string.
Example
=query({Sheet1!A:B;, Sheet2!A2:B}, "select * where Col1 > date 'YYYY-MM-DD' OR Col1 = 'example string' ")
The values are reflecting for date but not for the example string.
The example string entered for Col1 in the formula, is selected from a pulldown list in sheet2.
better try:
=FILTER({Sheet1!A:B; Sheet2!A2:B},
({Sheet1!A:A; Sheet2!A2:A}>"01/01/2000")+({Sheet1!A:A; Sheet2!A2:A}="example text"))
I have a sheet with a Name Column and corresponding Date column. I'm attempting to count the number of times unique Names appear for a specific Date range. The data is in a separate spreadsheet, so I'm using importrange in the formulas.
I created a sample spreadsheet here - we can pretend that the "Data" tab is on a separate spreadsheet file. I have the below formula so far but I'm not sure how to tell it to only count the unique Name values between the Dates in cells B2 and C2.
=QUERY(IMPORTRANGE("https://docs.google.com/spreadsheets/d/1VHR-T9bo0E1KH4yZp-9wTW6JGjKh4b3qMdm99MP_vB8/edit#gid=0","Data!A:B"),"Select Count(Col1) where Col2 >= date '"&TEXT(B2,"yyyy-mm-dd")&"' and Col2 <= date '"&TEXT(C2,"yyyy-mm-dd")&"' Label Count(Col1) ''")
Thanks for your help!
This formula should do it:
=COUNTUNIQUE(QUERY(IMPORTRANGE("1VHR-T9bo0E1KH4yZp-9wTW6JGjKh4b3qMdm99MP_vB8","Data!A2:B"),"select Col1 where Col2 >= date '"&TEXT(B2,"yyyy-mm-dd")&"' and Col2<= date '"&TEXT(C2,"yyyy-mm-dd")&"'",0))
I have the following table:
What I'm trying to do is to write a formula that totals by each unique day in the month and year given in B1 and C1 thus the output should be:
I'm not sure how to start with this, googling seems to suggest the use of SUMIF.
Sheet is here
try:
=QUERY(FILTER({A5:B, TIMEVALUE(C5:C)}, MONTH(A5:A)=MONTH(B1&1), YEAR(A5:A)=D1),
"select Col1,sum(Col3)
where Col1 is not null
group by Col1
label sum(Col3)''
format sum(Col3)'[hh]:mm'", 0)
I have 2 forms and I have their results on the same sheet. I used the following formula
=Query({importrange(...);importrange(...)}, "SELECT * where Col1 is not null")
I want to have all the results from 1 form and the results depending on the date from the other form on the same sheet.
I have tried the following formula for July
=Query({importrange(...);importrange(...)}, "WHERE month(Col1)=5")
but it shows ONLY the results with July in the date from both forms.
How can I combine the results?
EDIT 2
(following OP's concern)
...Looks like it works only when there are entries with July in the date in the second spreadsheet. I need all the entries in the first spreadsheet to be visualized at any time
We can easily fix that by wrapping the whole formula with the IFERROR function
=IFERROR({QUERY(IMPORTRANGE("xxxxxx","form1!A1:E"), "where Col1 is not null");
QUERY(IMPORTRANGE("xxxxxx","form2!A1:E"), "where Col1 is not null and month(todate(Col1))=6",0)},
QUERY(IMPORTRANGE("xxxxxx","form1!A1:E"), "where Col1 is not null"))
Just make sure that Col1 (the Timestamp) in your results sheet is formatted as Date time
This final formula says:
Import data from the 1st sheet and under it append data from the 2nd sheet based on a certain month.
If that month is missing (which results to an error), import data from just the 1st sheet.
EDIT
(following OP's clarification)
...but my results are not on the same spreadsheets. I'd like to keep them on different spreadsheets.
Since there are different spreadsheets involved you must use the IMPORTRANGE function (as you very correctly already do).
Then the formula would be:
={QUERY(IMPORTRANGE("xxxxxx","form1!A1:E"), "where Col1 is not null");
QUERY(IMPORTRANGE("xxxxxx","form2!A1:E"), "where Col1 is not null and month(todate(Col1))=6",0)}
(As before please adjust ranges to your needs. Just make sure you keep the same number of columns)
NOTES:
1. Though July is the 7th month, we use month(todate(Col1))=6. That is because in "query language" January is month 0 and not 1.
2. In our second part we use as headers 0. This way we get to avoid returning them for the second query.
3. Since the imports come from forms we keep open ranges so when new answers are submitted, then get imported as well.
If all your sheets are in the same spreadsheet, you do not need IMPORTRANGE.
Using INDEX -which is much "lighter"- your formula would be:
={QUERY({form1!A2:O29}, "where Col1 is not null");
QUERY({form2!A2:O29}, "WHERE month(Col1)=6")}
Now your form2 results will be placed under the ones from form1
Having an additional query, you can have them both ordered by the timestamp in column 1
=QUERY({QUERY({form1!A2:O29}, "where Col1 is not null");
QUERY({form2!A2:O29}, "WHERE month(Col1)=7")},"order by Col1")
(Please adjust all sheet names and ranges to your needs)
I have a spreadsheet with 2 sheets in it, I want to summarize the weekly results by date. I'm trying to use the query sum function to summarize everything since I wasn't able to do it with arrayformula.
but I'm not able to do it with a query as well. I don't want to just copy-paste the sum function from each row to the next I want to just type the date I need in column A and get all the results in the different columns.
https://docs.google.com/spreadsheets/d/1ZsKXw32ycO_5KGD2I-Ug_GmqSIB_Z-D3Z1jlGd6fpTE/edit?usp=sharing
link to sheets.
getting the data from the database sheet. I want to display the data-oriented by date and summed.
=ArrayFormula(IFERROR(FILTER(QUERY(DataBase!A2:E,"select A,sum(E)
where A is not null
group by A
label sum(E)''"), WEEKNUM(DataBase!A2:A)=WEEKNUM(A2:A))
))
I tried this formula and it dosent work..
=ARRAYFORMULA(IFERROR(VLOOKUP(A2:A,
QUERY(FILTER(DataBase!A2:E,WEEKNUM(DataBase!A2:A)=WEEKNUM(A2)),
"select Col1,sum(Col5)
where Col1 is not null
group by Col1
label sum(Col5)''"), 2, 0)))