=QUERY(IMPORTRANGE("xxxxxxx-Sheet-ID"; "Tabelle1!A:D"),
"where C > date'" & text(today(), "yyyy-mm-dd") & "'
and D < date'" & text(today(), "yyyy-mm-dd") & "'", 0)
Can someone told me, why this is not working?
I will get the row informations where the C date is smaller and the D date is bigger than today date.
I the table where i look is this formation 2021-03-29of date
I tried this code above but this is not working... It says ERROR! but i dont see any logs
Assuming you granted permission to pull data from other spreadsheets, try:
=QUERY(IMPORTRANGE("xxxxxxx-Sheet-ID"; "Tabelle1!A:D"); "where C > date '"& text(today(); "yyyy-mm-dd")&"' and D < date '"& text(today(); "yyyy-mm-dd") &"'"; 0)
and see if that works? If not, please share a copy of your spreadsheet (sensitive data erased) so we see how your data is structured.
Note that importrange is only needed if you import data from another spreadsheet. Data imports from within the same spreadsheet can be done without it.
You have to replace C by Col3 and D by Col4 (you can't use A, B, C and D in that case)
=query(IMPORTRANGE("___________","Tabelle1!A:D"), "where Col4 > date '"& text(today(), "yyyy-mm-dd")&"' and Col3 < date '"& text(today(), "yyyy-mm-dd") &"'", 0)
switch Col3 and Col4 as necessary
Related
I'm building a sales Dashboard for my company.
I use the following QUERY to list all my employees and their revenue:
=QUERY(Master!A2:O, "
SELECT F, SUM(O), SUM(G)
WHERE A >= date '" & text(D3,"yyyy-MM-dd") & "'
and A <= date '" & text(D5,"yyyy-MM-dd") & "'
AND UPPER(F) contains '"&$L3&"'
AND UPPER(D) contains '"&$L5&"'
GROUP BY F
ORDER BY SUM(G) DESC
LABEL SUM(G) 'Revenue', SUM(O) 'Work Hours', F 'Employee'
")
Some of the data are not attached to a person and their work hours, so I'd like to get rid of these results. To only List my Employees by Work Hours and Revenue.
Here is what I get out of this formula and on the right what I'd like to have:
I would like to cut out the irelevant Online Sales and the Employees who just worked bellow 10 Work Hours.
I tried bellow "GROUP BY F":
AND SUM(O) > 10
HAVING SUM(O) > 10
WHERE SUM(O) > 10
Somehow if I try to filter a SUM() it get's rejacted..
How can I fix that?
try:
=QUERY(QUERY(Master!A2:O,
"select F,sum(O),sum(G)
where A >= date '" &TEXT(D3, "e-m-d")&"'
and A <= date '" &TEXT(D5, "e-m-d")&"'
and upper(F) contains '"&$L3&"'
and upper(D) contains '"&$L5&"'
group by F
order by sum(G) desc
label sum(G)'Revenue',sum(O)'Work Hours',F'Employee'"),
"where Col2 > 10
and not Col1 contains 'Online Sales'", 1)
I have a Google Sheets filter formula that I need to replace with something, I was thinking QUERY, but I can't seem to make that work?
=FILTER(Food!$B:$K,Food!$A:$A=true,TODAY()>=Food!$C:$C,(Food!$D:$D-TODAY())<=14,NOT(ISBLANK(Food!$C:$C)),NOT(ISBLANK((Food!$D:$D-TODAY()))))
I need to IMPORTRANGE the filtered results and they lose their table formatting. I got QUERY working but with fixed dates. I have tried numerous combinations and can't seem to nail down the syntax.
Here is a copy of the sheet and the formula I need help with is in the Specials tab, A2.
https://docs.google.com/spreadsheets/d/16bAAI-A_EMsy1noj8U-fhIuT4XTbfgOJuxvzi_0hYhk/edit?usp=sharing
Thank you!
Does this formula do what you want?
=QUERY(Food!$A:$K,"select *
where A=TRUE
and (C > date '2000-01-01' and C < date '" & TEXT(TODAY(),"yyyy-mm-dd") & "')
and (D > date '2000-01-01' and D <= date '" & TEXT(TODAY()+14,"yyyy-mm-dd") & "') ",0)
The first date test for C and D is to ensure they aren't blank. Using C <> '' or C <> 0 didn't work, I guess since it is a date field.
UPDATE
My mistake - I left out some of the logic I'd included at first.
Try this:
=QUERY(Food!$A:$K,"select B,C,D,E
where A=TRUE
and (C > date '2000-01-01' and C <= date '" & TEXT(TODAY(), "yyyy-mm-dd") & "')
and (D > date '2000-01-01' and (D >= date '" & TEXT(TODAY(), "yyyy-mm-dd") & "'
and D <= date '" & TEXT(TODAY()+14,"yyyy-mm-dd") & "')) ",0)
I got it working by wrapping the FILTER in a QUERY. I had to improve the logic for an End Date >=TODAY() but it worked the way I need after the additional argument.
=QUERY(FILTER(Food!$B:$K,
Food!$A:$A=true,
TODAY()>=Food!$C:$C,
(Food!$D:$D>=TODAY()),
(Food!$D:$D-TODAY())<=14,
NOT(ISBLANK(Food!$C:$C)),
NOT(ISBLANK((Food!$D:$D-TODAY())))))
I'm happy to learn that I can QUERY(FILTER( then IMPORTRANGE the results properly.
Thanks for the interest.
I am in the process of creating a documentation tracker however struggling to do the following:
add conditional formatting so that the background changes colour (green, yellow, red) based on how many days since documentation has last been reviewed/updated. So that the background colours change depending on the number of days or months whichever is easier.
Based on the date, in the Action column for any dates greater than 3 months/90 days want it to automatically indicate check likewise for dates within a month or less no need to check
Link to documentation tracker google sheet: https://docs.google.com/spreadsheets/d/1DTyEg7JQcrTqCFQqgxrJEadOG8PcnI5khOrpOssZvyo/edit?usp=sharing
Example of a document which i got the status idea: https://docs.google.com/spreadsheets/d/1s8CXs-Q4qs7KeykxAlBF2cGfw7th-DGIqle6yLAVOxE/edit?usp=sharing
Thanks in advance! Will be extremely grateful for any help, guidance and advice!
Based on what you've provided so far, here is the basic conditional formatting to get you started.
https://docs.google.com/spreadsheets/d/1_AvM9sPlxUSlToqWf7t6oSKak5K7ALc_S4XjgO5o4q0/edit?usp=sharing
The custom formula for the conditional formatting looks like this:
=AND(TODAY()-E2 > 90, E2 <> "")
So if the date in E2 is older than 90 days, mark that cell in RED. This rule applies to the whole column, E2:E.
Similarly, a checkmark is added in the Action column for dates older than 90 days, by the formula in F1. Do you also mean that dates less than 30 days old should be always unchecked, but dates between 90 and 30 days, should be left as they are, either checked or not?
Let us know if this is what you are hoping for.
Update: The Action column is calculated based on the difference between today's date and your date value in Column E. It is really duplicating the RED highlighting, so doesn't really help you. If it is a field that you want to be able to update, you'll probably need to change the Arrayformula to a dragdown formula, which you cana then overtype if putting a checkmark in a cell.
Okay, it is not a very elegant solution, and I know some experts would have a much better solution, but I think it does what you want.
See my tab "Iteration 2-GK" in your new sheet.
You can change the dates in column I to see if the Summaries colours change the way you expect. I haven't done Technical or Stakeholders yet, but they would be the same.
I came up with a complex formula to apply the same logic used in the conditional formatting rules for Column I, to apply conditional formatting for column C. Note that I added a hidden column B, to add the ProductName onto each row. I also removed the merged cells in columns A-E.
The formula to check whether the dates in column I fall in a certain range, and then to count which range occurs most frequently (ie. also the most frequent colour in column I for each product) is:
=iferror(choose(
match(
max(
{iferror(query({B$3:B,I$3:I},
"select count(Col2) where Col1 = '"& B3 & "' and Col2 < date '"&TEXT(today()-180,"yyyy-mm-dd")&"' label count(Col2) '' ",0),""),
iferror(query({B$3:B,I$3:I},
"select count(Col2) where Col1 = '"& B3 & "' and Col2 < date '"&TEXT(today()-31,"yyyy-mm-dd")&"' and Col2 >= date '"&TEXT(today()-180,"yyyy-mm-dd")&"' label count(Col2) ''",0), ""),
iferror(query({B$3:B,I$3:I},
"select count(Col2) where Col1 = '"& B3 & "' and Col2 < date '"&TEXT(today() ,"yyyy-mm-dd")&"' and Col2 >= date '"&TEXT(today()-31, "yyyy-mm-dd")&"' label count(Col2) ''",0), "")}),
{iferror(query({B$3:B,I$3:I},
"select count(Col2) where Col1 = '"& B3 & "' and Col2 < date '"&TEXT(today()-180,"yyyy-mm-dd")&"' label count(Col2) '' ",0),""),
iferror(query({B$3:B,I$3:I},
"select count(Col2) where Col1 = '"& B3 & "' and Col2 < date '"&TEXT(today()-31,"yyyy-mm-dd")&"' and Col2 >= date '"&TEXT(today()-180,"yyyy-mm-dd")&"' label count(Col2) ''",0), ""),
iferror(query({B$3:B,I$3:I},
"select count(Col2) where Col1 = '"& B3 & "' and Col2 < date '"&TEXT(today() ,"yyyy-mm-dd")&"' and Col2 >= date '"&TEXT(today()-31, "yyyy-mm-dd")&"' label count(Col2) ''",0), "")},
0),"red","yellow","green"),"")
I haven't got this to work, so it needs to be dragged down column C from cell C3.
Will you need to add rows for a product, if you come up with more documentation? I haven't tested yet if this will work when adding rows.
I have a report I am developing that needs to be in google sheets
Sheet 1 contains all the current cases that are opened and owned by a case owner, 1 row per case, multiple cases per case owner per month (sample sheet has 4 months of data)
Sheet 2 contains all the cases that were closed and who closed them, 1 row per case, multiple cases per case owner per month (sample sheet has 4 months of data)
There could be case owners in the open sheet that don't exist in the closed sheet
There could be case owners in the closed sheet that don't exist in the open sheet
I know how create a query() function that summarises both raw data separately - what I want to be able to do is query a joined table to get open and closed cases in 1 table.
In the sample file there are 2 tables in A5 and F5. These were me looking at how the query() function worked - the actual report I want is in K5
Where I am struggling is bringing this together into one summary report which shows the last 3 months of data
To clarify - what I want to do is have one function that queries from the 2 RAW sheets and creates the summary report
The sample sheet should more clearly explain what I need to do
https://docs.google.com/spreadsheets/d/1QEd9ZauY0YrbRWNu35tDTk6SkL1PaIZLtSOCd1A2fDY/edit?usp=sharing
Output for the OPEN cases:
=query('Raw Data'!A:N,"Select B, count(A) where N >= date '2020-02-01' group by B pivot N")
Output for the CLOSED cases
=query('Raw Data - Closed'!A:N,"Select A, count(B) where H >= date '2020-02-01' AND H <= date '2020-04-01' group by A pivot H")
Any pointers?
try:
=ARRAYFORMULA(SUBSTITUTE(TRANSPOSE(QUERY(TRANSPOSE({{
IF(ISNUMBER(A5:D5*1), A5:D5&" A"&A3, A5:D5); A6:D},
IFNA(VLOOKUP(A5:A, {IF(ISNUMBER(F5:I5*1), F5:I5&" "&F3, F5:I5); F6:I},
COLUMN(G5:I5)-(COLUMN(F5)-1), 0))}), "order by Col1", 1)), " AOpen", " Open"))
=ARRAYFORMULA(SUBSTITUTE(TRANSPOSE(QUERY(TRANSPOSE({{
IF(ISNUMBER(
QUERY('Raw Data'!A:N, "select B,count(A) where N >= date '2020-02-01' group by B pivot N limit 0")*1),
QUERY('Raw Data'!A:N, "select B,count(A) where N >= date '2020-02-01' group by B pivot N limit 0")&" AOpen",
QUERY('Raw Data'!A:N, "select B,count(A) where N >= date '2020-02-01' group by B pivot N limit 0")); QUERY(
QUERY('Raw Data'!A:N, "select B,count(A) where N >= date '2020-02-01' group by B pivot N"), "offset 1", 0)},
IFNA(VLOOKUP(INDEX(
QUERY('Raw Data'!A:N, "select B,count(A) where N >= date '2020-02-01' group by B pivot N"),,1), {IF(ISNUMBER(
QUERY('Raw Data - Closed'!A:N, "select A,count(B) where H >= date '2020-02-01' and H <= date '2020-04-01' group by A pivot H limit 0")*1),
QUERY('Raw Data - Closed'!A:N, "select A,count(B) where H >= date '2020-02-01' and H <= date '2020-04-01' group by A pivot H limit 0")&" Closed",
QUERY('Raw Data - Closed'!A:N, "select A,count(B) where H >= date '2020-02-01' and H <= date '2020-04-01' group by A pivot H limit 0")); QUERY(
QUERY('Raw Data - Closed'!A:N, "select A,count(B) where H >= date '2020-02-01' and H <= date '2020-04-01' group by A pivot H"), "offset 1", 0)},
SEQUENCE(1, COLUMNS(
QUERY('Raw Data - Closed'!A:N, "select A,count(B) where H >= date '2020-02-01' and H <= date '2020-04-01' group by A pivot H"))-1, 2, 1), 0))}), "order by Col1", 1)), " AOpen", " Open"))
I am trying to combine two tabs of data to plan a daily routine. One tab is for recurring tasks and one for adhoc tasks.
The data on the tabs are mostly similar except on Sheet1 Col4 is a day of the week, whereas on Sheet2 Col4 is a date
What I would like is to choose the current day of the week and have the query return all recurring tasks for that day, as well as any adhoc tasks for that specific date
I can return both sets of data individually however I can't get the query to return both subsets together
Sheet1 Data
ID,TASK NAME,LOCATION,TASK DAY
REC1,Task 1,Office,Monday
REC2,Task 2,Office,Tuesday
REC3,Task 3,Field,Wednesday
REC4,Task 4,Office,Thursday
REC5,Task 5,Field,Friday
REC6,Task 6,Field,Monday
REC7,Task 7,Field,Tuesday
Sheet2 Data
ID,TASK NAME,LOCATION,TASK DATE
ADH1,AdHoc 1,Office,25/Jun/2019
ADH2,AdHoc 2,Office,26/Jun/2019
ADH3,AdHoc 3,Field,27/Jun/2019
ADH4,AdHoc 4,Office,28/Jun/2019
ADH5,AdHoc 5,Field,29/Jun/2019
ADH6,AdHoc 6,Field,30/Jun/2019
ADH7,AdHoc 7,Field,1/Jul/2019
This pulls the data from sheet 1 based on the day of the week in cell J1
=query({Sheet1!A:D}, "select Col1,Col2,Col3,Col4 where Col4 = """&J1&""" ",0)
This pulls the data from sheet 2 based on today()
=query({Sheet2!A:D}, "select Col1,Col2,Col3,Col4 where Col4 = date '" & text(today(),"yyyy-mm-dd") & "' ",0)
Thought this would work but merely returns an empty set
=query({Sheet2!A:D;Sheet1!A:D}, "select Col1,Col2,Col3,Col4 where Col4 = date '" & text(today(),"yyyy-mm-dd") & "' OR Col4="""&J1&""" and Col1<>'' ",0)
When J1 = Tuesday and date = 25/Jun/2019 I should get
ID,TASK NAME,LOCATION,TASK DAY
ADH1,AdHoc 1,Office,25/Jun/2019
REC2,Task 2,Office,Tuesday
REC7,Task 7,Field,Tuesday
but instead, merely get #N/A
You almost had it.
Rather than put the array inside the queries; put the queries inside the array.
={QUERY(Sheet1!A:D, "SELECT A, B, C, D WHERE D = """&J1&""" ");
QUERY(Sheet2!A2:D, "SELECT A, B, C, D WHERE D = date '" & text(today(),"yyyy-mm-dd") & "'")}
Credit - Stacking multiple query output in one sheet:
Might be too late but issue was in date column after converting it to text query works as well :
=query({Sheet2!A:D; Sheet1!A:D}, "select Col2,Col1,Col3,Col4 where (Col4='"&Sheet1!J1&"' OR Col4 = '" & to_text(today()) & "')",0)