This question already has an answer here:
How to compare dates or date against today with query on google sheets?
(1 answer)
Closed 3 years ago.
I have a problem with the query function in Google Sheets.
=QUERY(A1:D7; "Select B where C contains '"& F1 &"' ";0)
These formula works if the cell F1 contains a text or a number. But if it contains a date it turns with a N/A mistake.
As a result I need to get the data from the column B which is placed in the line with the certain date.
Please, could you help me? What do I do wrong?
for a date do:
=QUERY(A1:D7; "select B where A = date '"&TEXT(F1; "yyyy-mm-dd")&"'"; 0)
or do:
=ARRAYFORMULA(QUERY(TO_TEXT(A1:D7); "select Col2 where Col1 = '"&F1&"'"; 0))
Related
[Goal]
I want to create a table with the Query Function where it counts the number of 'Drivers' for each month in a dynamic manner. Meaning that when the data (example sheet is called 'Data') is updated, it'll be updated automatically as well.
[What I was able to do so far]
I was able to create a table with the Query Function, however, it only displays 1 column worth of Months when I want to show up to 4 months. And I also want to show the recent months from the left and the older months on the right.
[Formula that I have so far]
=QUERY(Data!$A:$B,"
SELECT B,
Count(B)
Where B != '' AND MONTH(A)=MONTH(DATE'"&TEXT(A2,"YYYY-MM-DD")&"')
Group By B
Pivot A
Order By B asc
Label B 'Drivers', Count(B) '"&TEXT(A2,"MMMM YYYY")&"'",1)
[Issue that I'm facing]
I've tried specifying the date range like the below, however there are 2 problems.
The date format is not mmmm yyyy (Example: May 2022) and it'd show as: 2022-2-1 May 2022
The months are ordered in an ascending manner (Example: 2022-2-1, 2022-3-1, 2022-4-1) instead of descending (Example: 2022-4-1, 2022-3-1, 2022-2-1)
So I'm not sure what I need to do to fix this. Hopefully I can have support.
Where B != '' AND MONTH(A)<=MONTH(DATE'"&TEXT(A2,"YYYY-MM-DD")&"')
AND MONTH(A)>=MONTH(DATE'"&TEXT(EDATE(A2,-3),"YYYY-MM-DD")&"')
[Sample Sheet]
https://docs.google.com/spreadsheets/d/1AJYTRga9-dXbj64nl4RfpDKs5JYSFwP2SiR7v7gAhMI/edit#gid=1297239620
=ARRAYFORMULA(REGEXREPLACE(""&TRANSPOSE(QUERY(TRANSPOSE(
QUERY({Data!A:B, TEXT(Data!A:A, "yyyymmdd×MMMM yyyy")},
"select Col2,count(Col2)
where Col2 != ''
AND MONTH(Col1)<=MONTH(DATE'"&TEXT(A2,"YYYY-MM-DD")&"')
AND MONTH(Col1)>=MONTH(DATE'"&TEXT(EDATE(A2,-3),"YYYY-MM-DD")&"')
group by Col2
pivot Col3", 1)),"order by Col1 desc")),"^(.*×)", ))
Reference:
How do I change the date format in a Google Sheets query pivot table with date filters?
Sort Query Pivot Table - Google Sheets
This question already has an answer here:
How to compare dates or date against today with query on google sheets?
(1 answer)
Closed 5 months ago.
I'm trying to get a Query formula to filter rows that have a past date in column B. Here's the formula:
=QUERY(users!A2:BB,"SELECT B, C, D, G, AI WHERE AM < "&DEVS!A2&"",1)
AM contains the row's date, and DEVS!A2 contains Today's date using the TODAY() formula.
I get one result in the row I have the Query on, but it doesn't automatically reutrn the other results.
The scenario is recreated in this sample sheet:
https://docs.google.com/spreadsheets/d/1_GXWOHW1nKzjRDvAJGnq8cpD_ewZIvzCTSH2lxJ8VhA/edit?usp=sharing
I was able to get it to work by using:
=QUERY(users!A2:BB,"SELECT B, C, D, G, AI WHERE AM < now() ",1)
use:
=QUERY(A2:B, "select A where B < date '"&TEXT(G2, "e-m-d")&"'", )
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
This question already has answers here:
Arrayformula sum one column until this row
(2 answers)
Closed 5 years ago.
I'm trying to print in column B the sum of all the previous rows of column A. Through the usual formulas this is done like this:
B1: = A1
B2: = A2 + B1
B3: = A3 + B2
B4: = A4 + B3
But I need to do this using arrayformula. I tried in A1 to enter this: =ARRAYFORMULA(IF(A1:A4<>"";SUM(INDIRECT("A1:A"&ROW(A1:A4)))))
(If I'm not mistaken, in the English version, instead of ";" is used ",")
But it does not work:
Tell me, please, how can I solve this problem using arrayformula?
Based on #TomSharpe's answer a while back:
=ARRAYFORMULA(SUMIF(ROW(A1:A4), "<="&ROW(A1:A4), A1:A4))
I am knew to google spreadsheet and trying to unite/consolidate two ranges in order, I am struggling hard with this & have written formula on spreadsheet but that is wrong.
Two Ranges are:
Range-1 = D1:F12
D1:D12 E1:E12 F1:F12
Word Date Name
Range-2 = G1:I12
G1:G12 H1:H12 I1:I12
Word Date Name
Now I want to unite/consolidate Range-1 & Range 2 where words should appear in column A, Date should appear in column B & Name should appear in column C & criteria is that date of new range should be in ascending order.
You may please see below mentioned link:
https://docs.google.com/spreadsheets/d/1tiKUdREYudh1htLIfh9VSWO27N5zCXwJAVKr0gqaSXE/edit#gid=0
Please help, thanks in advance.
try:
=query({D1:F; G1:I}, "where Col1 <>'' ")
and see if that works.
If you need it ordered by date:
=query({D1:F; G1:I}, "where Col1 <>'' order by Col2")