Data Sheet
Please assist a newbie with a query about query where 1 = Total Gross or Employers Cost based on the department and pay period.
So from the Data Sheet to a query on another sheet, I would be able to select February and Data it would produce Column C, D, I & J
Thanks in advance
Use this formula
=QUERY(Sheet1!A:J, "Select A, C, D, I, J Where A = '"&$B$3&"' ", 1)
Demo
Related
Here is a link to the doc
On sheet two cell A6 there is a query:
=QUERY('Events Summary'!1:970, "SELECT A,F,BG,M,BA,BB,BC,BD,BF,BE
WHERE F = date'"&text(Today(),"YYYY-MM-dd")&"'order by M DESC ",1)
The information for columns A, F, & M populates but the rest do not. Is this because they are out of their natural order?
it is empty because the source is empty:
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 want to make a report: "select salesmen who have N recent Status codes = 2,3,4,5".
A structural example of my data has 35 rows (including 1 header row):
link.
This file has a Date, Sales code (id of a salesman), Status code (id of how successful a transaction was) and other fields which are not necessary for the purpose.
I ended up using three formulas:
a QUERY function with IMPORTRANGE.In the example data it is slightly simpler - take only Sales Codes, Status Code, and Date from another sheet, then order by Date, Sales Code. Formula in A9:
=QUERY({Source!D1:E, Source!A1:A}, $B$4, 1)
an additional column with a sequentional numbering. Formula in D10:
=ArrayFormula(if(len(A10:A), ROW(A10:A) - MATCH(A10:A,A10:A,0) - 8, ))
a QUERY function to extract only N cases (let's say 5). Formula in F9:
=QUERY(A9:D, "select A, B where D <="&B3, 1)
Is there a way to combine all 3 steps into one so I get the output like in F10:G24 using one (and hopefully fast :)) formula? The formula I tried (expanded for readability):
=QUERY(
{
QUERY({Source!D1:E, Source!A1:A}, $B$4, 1),
ArrayFormula(
IF(len(J10:J),
ROW(J10:J) - MATCH(J10:J, J10:J, 0) - 8,
)
)
},
"select Col1, Col2 where Col4 <="&B3,
1
)
It gives me the error:
"Function ARRAY_ROW parameter 2 has mismatched row size. Expected: 28. Actual: 991."
I also tried finite data ranges in ROW() and MATCH() but that yields an empty table.
In the original database there are ~3500 rows and they will expand, so I think I should stick to infinite ranges to automate data extraction.
Hm well it's a bit of a nightmare TBH - a similar question has cropped up before but no easy answer. Here is a draft which involves repeating the basic query several times-
=ArrayFormula(query({query(A2:E,"select * where E>=2 and E<=5 order by D, A desc"),
row(indirect("2:"&count(filter(E2:E,E2:E>=2,E2:E<=5))+1))-
match(query(A2:E,"select D where E>=2 and E<=5 order by D, A desc"),
query(A2:E,"select D where E>=2 and E<=5 order by D, A desc"),0)
},"select * where Col6<=5"))
But needs looking at more to see if it can be simplified.
This is the full-column version including headers - I think it's OK
=ArrayFormula(query({query(A:E,"select * where E>=2 and E<=5 order by D, A desc"),
row(indirect("1:"&count(filter(E:E,E:E>=2,E:E<=5))+1))+1-
match(query(A:E,"select D where E>=2 and E<=5 order by D, A desc"),
query(A:E,"select D where E>=2 and E<=5 order by D, A desc"),0)
},"select * where Col6<=5"))
I want to get the total of entries in a column for a particular value. The values are a number such as 0.5 or 1 and then a code such a H, S, O or WFH. i.e "0.5 H" or "1 S"
It is a absence spreadsheet recording holiday, sickness, appointments and working from home. One sheet has a row for every day in the year, the columns represent all the staff members. I wish to be able to query the values under the columns and then summarise that per staff member / per month.
I have googled but not found anything similar enough to put me in the right direction.
Any help would be greatly appreciated.
query function might help you:
about
Query Language Reference
Please, provide data sample to get more help.
your query will look like this:
=query({A:D}, "select Col1, Col2, sum(Col4) where Col3 = '1 S' group by Col1, Col2")
In this sample query formula summarises data in A:D per columns A, B (Col1, Col2) and checks the value in column C (Col3) eqwuals '1 S'.
my question isn't exactly about programming but I need help with google spreadsheets.
So my problem is visible here: https://docs.google.com/spreadsheets/d/1OP_ottKUgSWOoU4hNSYz6X3dN67Z4KiALN0spWm9KoI/edit?usp=sharing
I am a teacher and I have a class of students that is being divided into three teams: yellow, red and green. Each member of a team has to perform the same task three times a week (namely run1, run2 and run3). Every week I calculate the average of the performance of each student (300s = best). What I would like to know is which team is the most efficient. In the < Average > sheet I want to retrieve only the average value of each student without doing manually copy-paste.
I thought I could use the query command but it fails to give me what I need.
Check out this copy of your spreadsheet and take a look at the sheet 'JP' where I entered in cell A3:
=query(Students!A3:AA, "select A, B, C, G, K, O, S, W, AA")
This formula imports only the columns with the averages.
Then in cell K3, I added a second query
=query(C2:I, "select C, sum(D), sum(E), sum(F), sum(G), sum(H), sum(I) where C <>'' group by C ", 1)
that sums the averages per group (color), per week.
See if that helps ?