Very strange, a query function I have used for years with no issue is not working on my latest google sheet.
It keeps saying no output even though I know it should have an output.
This is the query
=(Query(Results!A2:E,"Select A,C,B,D,E Where A >= date '"&TEXT(B10,"yyyy-MM-dd")&"' and A <= date '"&TEXT(B10,"yyyy-MM-dd")&"' "&if(len(J6)," and C='"&J6&"' ",)&" Order by A Desc",0))
You can view the sheet at:
https://docs.google.com/spreadsheets/d/1vobnovcVLpMM3lbbDXPekNAkoj_zhlG5Kd5ksQg5rVg/edit?usp=sharing
Your help is greatly appreciated
Transform Column A in dates by
=arrayformula(iferror(int(A2:A*1),date("20"&mid(A2:A,7,2),mid(A2:A,1,2),mid(A2:A,4,2))*1))
try:
=ARRAYFORMULA(QUERY({TO_DATE(1*REGEXREPLACE(TO_TEXT(Results!A2:A),
"(\d+)/(\d+)/(\d+)(?:.*)?", "$2/$1/$3")), Results!A2:F},
"select Col1,Col4,Col3,Col5,Col6
where Col1 >= date '"&TEXT(D4, "yyyy-MM-dd")&"'
and Col1 <= date '"&TEXT(G4, "yyyy-MM-dd")&"'"&IF(LEN(J6),"
and Col4='"&J6&"' ",)&"
order by Col1 desc", 0))
Related
I'm trying to count the number of most frequent text in a column, I have this formula that I used before in excel...
=INDEX(E9:E18,MODE(IF((E9:E18<>"")*ISNA(MATCH(E9:E18,$B$1:$B1,0)),MATCH(E9:E18,E9:E18,0))))
This works, but when I get some repited value shows #N/A
Here is an capture from this I would like to know how can I resolve this I tried with
=INDEX(E9:E18,MODE(IF(AND(E9:E18<>"")*ISNA(MATCH(E9:E18,$B$1:$B1,0)),MATCH(E9:E18,E9:E18,0))))
But I get lost trying to put a condition like only one value = value
Some help or code that I could use?
So this is my problem
With Office 365:
=INDEX( SORTBY(UNIQUE(A1:A10), COUNTIF( A1:A10, UNIQUE(A1:A10) ),-1), 1 )
Oops - i just saw the Google sheets edit.
For most frequent:
=INDEX( SORT(UNIQUE(A1:A10), COUNTIF( A1:A10, UNIQUE(A1:A10) ),0), 1 )
For Just One Value:
=FILTER(UNIQUE(A1:A10),COUNTIF(A1:A10,UNIQUE(A1:A10))=1)
try:
=QUERY({A:A};
"select Col1,count(Col1)
where Col1 is not null
group by Col1
label count(Col1)''")
Context
Following on from this question, I am trying to make this more dynamic. I want to input data in a cell 'D1' to then make Query bring back the data from another spreadsheet. Below is a depiction of what this looks like.
This is the formula I tried:
=QUERY(Query(ImportRange("ID", "AvevaGroupPrice"),"offset 1", 0), "where Col1 >= Date " &D1)
I used this format because eventually I want to create a dynamic date range where I type the respective dates I need in the first two 'D' rows.
Problem
How can I make this work using data in cell D1?
Based on the Query Language Documentation, when you include date keyword you need to use a date with yyyy-mm-dd format
In your current function, the date was converted to a number when appended to the string.
Sample: ="date "&D1
Result: date 43830
You need to use TEXT() to convert the date to yyyy-mm-dd format.
Sample: ="where Col1 >= Date '"&TEXT(D1,"yyyy-mm-dd")&"'"
Result: where Col1 >= Date '2019-12-31'
(UPDATE)
You can also use TO_TEXT() to convert the Cell Value to a text value.
Sample: ="where Col1 >= Date '"&To_text(D1)&"'"
Result: where Col1 >= Date '2019-12-31'
Your Formula:
=QUERY(Query(ImportRange("ID", "AvevaGroupPrice"),"offset 1", 0), "where Col1 >= Date '"&TEXT(D1,"yyyy-mm-dd")&"'")
or
=QUERY(Query(ImportRange("ID", "AvevaGroupPrice"),"offset 1", 0), "where Col1 >= Date '"&To_text(D1)&"'")
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 a spreadsheet that has data in one column (H2:H500) and dates in another column (F2:F500). I would like a sum of the total number in the past work week (Monday-Friday). I'm not sure if I need to use =CountIfs or what. Any help would be greatly appreciated!
=COUNTIFS(F2:F500,WEEKNUM(TODAY(),1),H2:H500, "<>")
...doesn't seem to work. Am I close?
=COUNTA(QUERY({A2:B},
"select Col1
where Col2 is not null
and Col1 >= date '"&TEXT(DATE(YEAR(TODAY()),1,1)-WEEKDAY(DATE(YEAR(TODAY()),1,1),3)+7*
(WEEKDAY(DATE(YEAR(TODAY()),1,1),3)>3)+7*(WEEKNUM(TODAY())-2),"yyyy-mm-dd")&"'
and Col1 <= date '"&TEXT(DATE(YEAR(TODAY()),1,1)-WEEKDAY(DATE(YEAR(TODAY()),1,1),3)+7*
(WEEKDAY(DATE(YEAR(TODAY()),1,1),3)>3)+7*(WEEKNUM(TODAY())-2)+4,"yyyy-mm-dd")&"'"))
I have a Query formula in Google Sheets where I'm trying to set a condition that shows rows where Col1 > (Col2 +15 days). I'm not sure how to do the math on the +15 days in the Query formula.
I tried the following code:
=Query(A:B,"Select * where Col1>Col2+15")
I want it to show me where Column 1 is greater than the Col2 date + 15 days
Or you can use Datediff within your query:
=Query(A:B,"Select * where A is not null and datediff(A,B)>15")
See
I would add into the query {A:B,B:B+15}. This will add a third column into your selection with Col2+15 days. Then from there, you can select the first two columns, but still ask whether Col1 is greater than Col3.
=arrayformula(query({A:B,B:B+15},"select Col1,Col2 where Col1 > Col3"))
=ARRAYFORMULA(TO_DATE(QUERY(VALUE(A1:B),
"select * where Col1 > Col2+15", 0)))