Google Sheets offers passing in parameters to lambdas as such:
=LAMBDA(x, y, x + y)(100, 200)
I was thinking of taking 2 columns from another Sheet, filter it with QUERY and then pass those 2 columns into the LAMBDA. Basically the 2 columns were a key and a CSV text that I wanted to split in one go.
=lambda(a, b, split(b, ","))(query('Alias Key Raw'!A1:B, "select * where A starts with 'X'"))
This gives the following ERROR Wrong number of arguments to call following LAMBDA function. Expected 2 arguments, but got 1 arguments.. Given that QUERY provides 2 columns of actual values, I thought this would be possible.
=byrow(query('Alias Key Raw'!A1:B, "select * where A starts with 'X'"), lambda(row, split(row, ",")))
This gives me only column A. No error otherwise. All of column B is ignored it appears
I've tried using BYCOL, BYROW, etc, and a lot of errors are ERROR Wrong number of arguments to call following LAMBDA function. Expected 2 arguments, but got 1 arguments.
Data
Input into the lambda
Key
Lineages
CU
B.1.1.529.5.1.26
CV
B.1.1.529.2.75.3.1.1.3
XA
B.1.1.7,B.1.177
XB
B.1.634,B.1.631
XC
AY.29,B.1.1.7
XAZ
BA.2.5,BA.5,BA.2.5
XBC
BA.2*,B.1.617.2*,BA.2*,B.1.617.2*
Expected
Output from the lambda
Key
Lineages
XA
B.1.1.7
B.1.177
XB
B.1.634
B.1.631
XC
AY.29
B.1.1.7
XAZ
BA.2.5
BA.5
BA.2.5
XBC
BA.2*
B.1.617.2*
BA.2*
B.1.617.2*
Note: There can be any number of lineages in the CSV cell
Updated
=ArrayFormula(
LAMBDA(a, {QUERY({a},"Select Col1"),SPLIT(QUERY({a},"Select Col2"),",")})
(QUERY('Alias Key Raw'!A1:B, "select * where A starts with 'X'",1)))
Explanaition:
using an Array {} to return:
Col1: {QUERY({a},"Select Col1"),...}
Col2: {...,SPLIT(QUERY({a},"Select Col2"),",")}
Of the Query QUERY('Alias Key Raw'!A1:B, "select * where A starts with 'X'",1) found in the Lambda call named a
Used formulas help
ARRAYFORMULA - LAMBDA - QUERY - SPLIT
Perhaps worth pointing out that the expected data can be returned with a more compact formula that uses neither QUERY nor LAMBDA:
=filter({A1:A,split(B1:B,",")},regexmatch(A1:A,"^X"))
Related
I try to run this query:
=Query({'raw_13-19'!A:G},"Select * where C ={'Keyword'!G2:G19}", 1)
But it keeps returning:
Unable to parse query string for Function QUERY parameter 2: PARSE_ERROR: Encountered " <ID> "C "" at line 1, column 16. Was expecting one of: "(" ... "(" ...
I'm not quite sure why is this happening. Can anyone help?
Since the range is within {}, you need to use the other select notation 'Col1,Col2,Col3' instead of 'A,B,C'.
Also {'Keyword'!G2:G19} won't work, but you should use textjoin() instead.
Try:
=Query({'raw_13-19'!A:G},"Select * where Col3 matches '"&textjoin("|",1,Keyword!G2:G19)&"' ", 0)
If you have a header column on raw_13-19, then change , 0 at the end to , 1.
NOTE: the above will work with text fields, but if you have any issues, please share a mockup sheet so we can see the actual data scenario.
I'm trying to filter some rows of this sheet
Google sheet sample image
I'm using the following query:
=query(Jira_query!$A:$I;"SELECT A WHERE E contains '&SDP&' AND C IN ('To Do','In Progress')")
But I'm only getting this error:
Error
PARSE_ERROR: Encountered " "C "" at line 1, column 39. Was expecting one of: "(" ... "(" ...
I would appreciate some help here, thanks!
Get rid of the ampersands before and after SDP. That is a string literal and should just be sitting between the single quotes.
In addition, I don't think QUERY supports IN; instead, use MATCHES with a pipe-separated list.
Finally, you only need to reference A:E in the QUERY, since you don't reference any columns beyond E in the SELECT clause.
So try this:
=QUERY(Jira_query!$A:$E;"SELECT A WHERE E CONTAINS 'SDP' AND C MATCHES 'To Do|In Progress'")
Let me know how can I solve or write query in influx for this scenario ( flux or influx query will work for me )
I have a field called x and m. There is a function in influx called difference which takes the difference between the first and the next field value.
I would like to take the difference between x and next x value and also would like to have the next m value as the row
so this is what I require as a single row
(x_next - x), m_next
.....
How can I do that in influx of flux queries. I can have x_next-x using difference but how to get m_next in this.
select difference(x), moving_average(m)+0.5*difference(m) from mydata
is the closest solution you can use without group by time.
i m searching sum of class of each student using countif formula, but any student have unique username like A*di (in the image) and so the calculation is false. And any other student using username like </John>, and 'Angel. and make calculation false
Formula: =COUNTIF('Data Asli'!$A:$A,$A$2)
Use SUMPRODUCT(--EXACT(..)) to run an exact, case-sensitive comparison that ignores wildcards:
=SUMPRODUCT(--EXACT('Data Asli'!$A:$A,$A2))
How it works:
EXACT(Value1, Value2) will return TRUE or FALSE, depending on whether the 2 values exactly match (same capitals, no wildcards, et cetera)
-- will convert TRUE/FALSE into 1/0
SUMPRODUCT(Array1[,Array2]) will run down the arrays, multiply the numbers together, then add them. It also forces many functions to both treat a Range as an array, and output an array.
So, as an example, the steps run like this:
=SUMPRODUCT(--EXACT(A1:A5, A2))
=SUMPRODUCT(--EXACT({Value1,Value2,Value3,Value4,Value2}, Value2))
a.k.a.
=SUMPRODUCT(--{EXACT(Value1,Value2),EXACT(Value2,Value2),EXACT(Value3,Value2),EXACT(Value4,Value2),EXACT(Value2,Value2)})
=SUMPRODUCT(--{FALSE,TRUE,FALSE,FALSE,TRUE})
=SUMPRODUCT({0,1,0,0,1})
=2
I try to do something the following division using sum over two columns like this.
Report.sum('(clicks_count / nullif(sum(views_count),0))')
But I get the error PG::GroupingError: ERROR: aggregate function calls cannot be nested.
I'm a bit stuck in how to perform this query in ActiveRecord, any idea?
Try Report.sum(clicks_count) / Report.sum(view_count).
If you'd like to use only one query, then you can use pluck:
Report.pluck('sum(clicks_count) / nullif(sum(views_count),0))').first
You can also group by another attribute (for example date):
Report.group(:date).pluck('sum(clicks_count) / nullif(sum(views_count),0))')
This will give you the clicks_count sum divided by views_count sum for each date.