I have a strange problem with the Google Sheets QUERY function and COUNT. I made an easy example to show the problem:
https://docs.google.com/spreadsheets/d/1wA5c-1NYpKZ58d6It728EGbTCeRfEzXd_JXN02U0odg/edit?usp=sharing
When there is no date (01.01.2021) in the data, everything works fine. If there is a date in the data the QUERY function stops working/counting. It starts counting again below the date.
/EDIT: Screenshots:
No date, works fine
Function (red cell):
=query(A2:C5;"SELECT COUNT(A) WHERE A='a' AND C='Yes' LABEL COUNT(A)''")
With date, stops working
Function (red cell):
=query(A9:C12;"SELECT COUNT(A) WHERE A='a' AND C='Yes' LABEL COUNT(A)''")
Still counts below the date
Function (red cell):
=query(A16:C19;"SELECT COUNT(A) WHERE A='b' AND C='Yes' LABEL COUNT(A)''")
Try:
=query(A9:C12;"SELECT COUNT(A) WHERE A='a' AND C='Yes' LABEL COUNT(A)''";0)
You need the ;0 header at the end.
Related
I have a Google sheet that I want to apply conditional formatting, the formula I have now doesn't seem to work as it still highlights rows that I want to ignore.
I have about 15 columns of data but only want to focus on columns B,C,D
B Order status
C Date ordered
D Ship by date
Originally, I was trying to only highlight rows that are overdue.
So that if the date in D cell is today onward it would make the row red, but, to ignore this rule if the status in B cell is 'fulfilled'.
This formula ( I had someone do for me ) kept giving random results
=IF(AND($D1 > TODAY(),$B1 <> "FULFILLED"),TRUE,FALSE)
I would also like to add 2 other conditions to colour grade rows.
-To mark the rows as green from order date up to 3 days before the due date
-To mark the rows as orange 3 days before and up until the due date.
So that orders that have not been fulfilled will go from green to orange to red.
If unclear, I can provide more information.
WORKING ANSWER:
=IF(AND($B2 <> "FULFILLED",$D2 <TODAY()),TRUE,FALSE)
Link
I'm trying to calculate values with an arrayformula, based on the last 14 days (the last 14 rows, since every row is 1 day).
I want N110:N to have the values (in example: sum) from, let's say, I96:I110.
Means, the values in N110 should be sum(I96:I110). For N111 it should be sum(I97:I111) etc.
I have something like = ARRAYFORMULA("I"& Row(I110:I)-14 & ":I" & Row(I110:I)) which returns
I96:I110
I97:I111
I98:I112
...
in each row.
I cannot wrap this into the arrayformula, since Indirect() is not working here and is returning only the first value.
I also tried with offset, which led to the same result.
Basically I'm trying to use an arrayformula to calc values by a dynamic offset range with a fixed size (14).
I could solve it with google apps script, but I want to try with arrayformula.
try:
=INDEX(IFNA(VLOOKUP(ROW(A1:A),
QUERY(SPLIT(FLATTEN(ROW(A1:A)&"×"&ARRAY_CONSTRAIN(
SPLIT(FLATTEN(QUERY(TRANSPOSE(IF(ROW(A1:A)<=TRANSPOSE(ROW(A1:A))=TRUE,
TRANSPOSE(A1:A)&"×", )),,9^9)), "×"), 9^9, 14 +N("14 day window"))), "×"),
"select Col1,sum(Col2)
where Col2 is not null
group by Col1"), 2, )))
Make sure that N110:N is empty, and then place the following formula in N110:
=ArrayFormula(IF(I110:I="",,SUMIF(ROW(I96:I),"<="&ROW(I110:I),I96:I)-SUMIF(ROW(I96:I),"<="&ROW(I110:I)-15,I96:I)))
This formula assumes that there are no blank cells interspersed between numbers in I96:I (though there may be blank cells after the number list runs out).
Essentially, this sums all cells in in the range up to the current row and then subtracts the total of all cells in rows prior to "15 cells back" as marked from the current cell.
I have a list of items in column A. In column B I want to use an ARRAYFORMULA function that will bring the serial number of each item to appear - 1 next to the first item, 2 next to the second etc.
This formula works fine but breaks when there are blank rows:
=ARRAYFORMULA(IF(LEN(A2:A),ROW(A2:A)-1,""))
This formula works nice but I need to drag it which I don't want to do. This is why I want it as an ARRAYFORMULA (note that I fix the range to always start from A$1 so only the range changes in size as I drag it further down).
=IF(LEN(A2),COUNTA(A$1:A2),"")
What I need is basically something that will work like the 2nd formula but with an ARRAYFORMULA.
Here's a spreadsheet to make it clearer (col A is the list, col C is function 1 and col D is function 2):
https://docs.google.com/spreadsheets/d/17qVGwvFJVrxdwkgmVQatH3Urpjl0_xB8EGqUsPVIwl8/edit?usp=sharing
In F2 I entered
=ArrayFormula(if(len(A2:A), countifs(A2:A, "<>", row(A2:A), "<="&row(A2:A)),))
See if that works for you?
I have built a simple task tracker in Google sheet.
There is column B handling the status (In progress, Done) and Due date column C.
I have created to formulas: exact match for B that sets the color to green and date before today for C that sets the red color.
The problem is that they work independently. Red color is displayed for C even when B is Done.
And each rule highlights different column.
Text is exactly Done
Date is before =today()
How to make the date formatter ignore the past dues when the task status is set to Done?
You mentioned
exact match for B that sets the color to green and
date before today for C that sets the red color
Try the following formula under Custom formula is
=AND(C3<TODAY(),B3<>"Done", C3<>"")
(Do adjust ranges to your needs)
I am using google sheets and have the following format,
I want to get Col3 from Col1 and Col2. As you can see the spaces after Col1 elements are dynamic and that is why its hard to keep track of how many rows to append.
I would have added some code, but I have no idea where to begin. Kindly give me some direction.
This is difficult to do without a sample spreadsheet but there is a chance that this works if you put it in cell C2 and drag it down column C
=IF(A2="",,TEXTJOIN(", ",TRUE,FILTER(B:B,LOOKUP(ROW(A:A),FILTER(ROW(A:A),A:A<>""))=LOOKUP(ROW(A2),FILTER(ROW(A:A),A:A<>"")))))
Formulas used:
FILTER()
ROW()
TEXTJOIN()
LOOKUP()