Conditional formatting days passed "10 day(s)" - google-sheets

Info in F cell tells us the time stamp. Corresponding G cell shows times passed.
Need conditionally formatting G cells for days passed.
2 day(s)
5 day(s)
10 day(s)
Because the formula isn't straightforward I have not found a simple way to conditionally format it.
i only did dates between "1d and 3d", some of it works but when it gets to 10d it screws up, or it's all random.
conditional formatting as it is, wrong
"=IF(DATEDIF(F17, $F$2, "D")>365, QUOTIENT(DATEDIF(F17, $F$2, "D"), 365)&" year(s) "&
QUOTIENT(MOD(DATEDIF(F17, $F$2, "D"), 365), 30)&" month(s) "&
MOD(QUOTIENT(MOD(DATEDIF(F17, $F$2, "D"), 365), 30), 30)&" day(s)",
IF(DATEDIF(F17, $F$2, "D")>30, QUOTIENT(DATEDIF(F17, $F$2, "D"), 30)&" month(s) "&
MOD(DATEDIF(F17, $F$2, "D"), 30)&" day(s)",
DATEDIF(F17, $F$2, "D")&" day(s)"))"
Here is the link to the spreadsheet.
https://docs.google.com/spreadsheets/d/1b6nXGCqZo82aqIzqvJUlYdgFf0i8WBuJoGK2k792OAk/edit?usp=sharing
Thank you.

This isn't specifically what you asked for in your post (and "player0" has you covered there); but you could also benefit from an array formula in your sheet range G3:G. If you want to try that, delete everything from G3:G and then place the following formula in cell G3:
=ArrayFormula(IF(F3:F="",, IF(DATEDIF(F3:F, $F$2, "Y")<1,, DATEDIF(F3:F, $F$2, "Y")&" year"&IF(DATEDIF(F3:F, $F$2, "Y")=1,, "s")&" ")& IF(DATEDIF(F3:F, $F$2, "M")<1,,MOD(DATEDIF(F3:F, $F$2, "M"), 12)&" month"&IF(MOD(DATEDIF(F3:F, $F$2, "M"), 12)=1,, "s")&" ")& IF(DAY($F$2)>=DAY(F3:F),DAY($F$2)-DAY(F3:F),30-DAY(F3:F)+DAY($F$2))&" day"&IF(IF(DAY($F$2)>=DAY(F3:F),DAY($F$2)-DAY(F3:F),30-DAY(F3:F)+DAY($F$2))=1,, "s")))
This will return all results for all non-null rows.
It will also be "cleaner" (e.g., adding "s" to units only when needed) and more accurate than your original formulas.

try:
=F$2-F3<3
=F$2-F3<6
=F$2-F3<10
=F$2-F3<16
demo sheet

Related

Marking employees' names if detecting their time of working shifts are too close

I am designing a formula to warn the time of work shifts of the same employee conflicting. Based on the working schedule on A row to arrange the work shifts of every employee. The general working time is 3 hours. For an example of a picture, Andy in the table has arranged a shift at 2021/10/23 22:00, however, accidentally arranges andy works again at 2021/10/24 01:45, and his previous three hours work times have not been completed, which conflicts, so I hope to design that when his name is marked in the B row, it will be marked as a reminder. According to the picture, I originally designed an index and Match function in the D row to catch The names of employees with conflicting working hours are distinguished by V and X, but it seems that this group of functions cannot be successful. I would like to ask if there is a correct solution to solve it, thank you for your assistance.
add helper column:
=INDEX(IF(B:B="",,REGEXMATCH(B:B&COUNTIFS(B:B, B:B, ROW(B:B), "<="&ROW(B:B)),
TEXTJOIN("|", 1, "×", IF(0.125>IFNA(ABS(QUERY(
TRANSPOSE(SPLIT(FLATTEN(QUERY(QUERY(QUERY({1*A:A, B:B},
"select max(Col1) where Col2 is not null group by Col1 pivot Col2"),
"offset 1", ),,9^9)), " ")), "offset 1", )-
TRANSPOSE(SPLIT(FLATTEN(QUERY(QUERY(QUERY({1*A:A, B:B},
"select max(Col1) where Col2 is not null group by Col1 pivot Col2"),
"offset 1", ),,9^9)), " "))), 99), TRANSPOSE(SORT(UNIQUE(B:B)))&ROW(A:A)+1, )))))
you can change ranges to fit your needs just dont change last ROW(A:A)+1

Forming a Line of Row of Date from just Two Cells Information Google Sheet

I have list of assets
There is information about buy date and buy value
there is information about depreciation year
I want to make the year of each deprecation and the depreciation value, be described yearly from top to down automatically
I prefer array formula to prevent me from dragging the formula every now and then
here is the link of the case:
https://docs.google.com/spreadsheets/d/1wJ65_Q3bD1Fz_ueW2cmQP_L03r8U2jvbMXstzzjMDb8/edit#gid=0
yellow cells are raw data
green cells are expected form of output
thankyou in advance!
try:
=ARRAYFORMULA(SPLIT(FLATTEN(QUERY(TRANSPOSE(QUERY({(SPLIT(QUERY(FLATTEN(IFERROR(SPLIT(
REPT(A2:A&"×♦"&TEXT(B2:B, "d mmm")&"×"&YEAR(B2:B)&"×♦"&D2:D/C2:C&"¤", C2:C), "¤"))),
"where Col1 is not null"), "×")), COUNTIFS(
SPLIT(QUERY(FLATTEN(IFERROR(SPLIT(REPT(B2:B&"¤", C2:C), "¤"))),
"where Col1 is not null"), "×"),
SPLIT(QUERY(FLATTEN(IFERROR(SPLIT(REPT(B2:B&"¤", C2:C), "¤"))),
"where Col1 is not null"), "×"), SEQUENCE(SUM(C2:C)), "<="&SEQUENCE(SUM(C2:C)))},
"select Col1,Col2,Col3+Col5,Col4 label Col3+Col5''")),,9^9)), "♦"))

Conditional Formatting Dates whereby specific date range auto-suggests action

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.

Google Sheets ArrayFormula Sort & Split Issue

Have been researching several places for a solution and found something that quasi works but doesn't work in the ArrayFormula for Sheets. I have data in a single column as an example below. It's a combination of letters and text but would otherwise been sortable when parsed. The goal is to populate the cell with the single most recent event (as measured by the highest number at the end of the string). The value "Sprint" is consistent text. This formula seems to work for that purpose, however, I would ideally like this to work within the ArrayFormula so that it would adjust and populate with the data rows it's referencing which is dynamic. Thanks in advance.
TRIM(CHOOSE(1,SPLIT(JOIN(";",SORT(TRANSPOSE(SPLIT([#CELL],";",FALSE)),1,FALSE)),";")))
Below is a sample set of data:
Sprint 1
Sprint 2
Sprint 3
Sprint 3;Sprint 1
Sprint 1;Sprint 2
try:
=ARRAYFORMULA(B1&" "&QUERY(TRANSPOSE(QUERY(TRANSPOSE(
REGEXREPLACE(IFERROR(SPLIT(B2:B, ";")), "\D+", )*1),
"select "&TEXTJOIN(",", 1, IF(B2:B<>"",
"max(Col"&ROW(B2:B)-ROW(B2)+1&")", ))&"")),
"select Col2"))
UPDATE:
=ARRAYFORMULA(IF(REGEXMATCH(B2:B, B1),
B1&" "&QUERY(TRANSPOSE(QUERY(TRANSPOSE(
REGEXREPLACE(IFERROR(SPLIT(B2:B, ";")), "\D+", )*1),
"select "&TEXTJOIN(",", 1,
"max(Col"&ROW(B2:B)-ROW(B2)+1&")")&"")),
"select Col2"), ))

How to use COUNTUNIQUE function within ArrayFormula and get a range result?

I have tried to use a COUNTUNIQUE function within ArrayFormula in cell 'A2' to get a result in the range like a column B that I've set a function cell by cell. But it returns only a single value. This is my formula in cell 'A2':
=ArrayFormula(COUNTUNIQUE(D2:D7,E2:E7,F2:F7,G2:G7,H2:H7))
Any help will be greatly appreciated!
This problem has interested me for a while. Basically, the solution from #player0 seems obvious to me. But it is difficult to read.
Perhaps using combined arrays and implicit endings search is more appropriate:
=INDEX(
COUNTIF(
UNIQUE(FLATTEN(
{"" & ROW(C2:Z), ROW(C2:Z) & "-" & C2:Z}
)),
ROW(C2:Z7) & "-*"
) - 1
)
you can do it like this:
=ARRAYFORMULA(QUERY(UNIQUE(TRIM(SPLIT(TRANSPOSE(SPLIT(QUERY(TRANSPOSE(QUERY(TRANSPOSE(
IF(D2:K<>"", "♦"&ROW(A2:A)&"♥"&D2:K, )),,999^99)),,999^99), "♦")), "♥"))),
"select count(Col1) where Col1 is not null group by Col1 label count(Col1)''", 0))
or like this:
=ARRAYFORMULA({
COUNTUNIQUE(D2:H2);
COUNTUNIQUE(D3:H3);
COUNTUNIQUE(D4:H4);
COUNTUNIQUE(D5:H5);
COUNTUNIQUE(D6:H6);
COUNTUNIQUE(D7:H7)})

Resources