Formula for increment text value - google-sheets

I have the column with a combination of text and number - T-00001. I would like to have the formula to get T-00002, T-00003, and so on. I tried to use CONCATENATE("T-",RIGHT("T-00001",5)+1) but I get T-2, without 4 nulls. Is it possible to receive it in the correct format?

if you want to drag it use:
=TEXT(ROW(A1), "T-00000")
if not, use:
=INDEX(IF(A2:A="",,TEXT(ROW(A1:A), "T-00000")))
if you plan empty rows use:
=INDEX(IF(A2:A="",,TEXT(COUNTIFS(A2:A, "<>", ROW(A2:A), "<="&ROW(A2:A)), "T-00000")))
for fixed range:
=INDEX(TEXT(SEQUENCE(20), "T-00000"))
to increment ony with each unique:
=INDEX(IFNA(TEXT(VLOOKUP(A2:A, {UNIQUE(FILTER(A2:A, A2:A<>"")),
SEQUENCE(COUNTUNIQUE(A2:A))}, 2, 0), "T-00000")))

Related

Replacing the blank cells with specific value

I'm trying to change the blank cells into specific value of 16. However, the value it shows is like 44877. I tried changing the format, but it won't change.
The link is here: sample sheet
Thank you so much
Use isblank(), like this:
=arrayformula(
ifs(
isblank(A2:A), 16,
today() - A2:A > 1, today() - A2:A,
today() - A2:A < -1, 0,
true, iferror(1/0)
)
)
In the event the cells you call "blank" are actually not blank but contain a formula that yields zero-length text strings "", you need to consider that zero-length text strings are different from truly blank values.
To detect both zero-length text strings and truly blank values, replace isblank(A2:A) with not(len(A2:A)).
44877 is the dateserial value for today, 12 November 2022. See this answer for an explanation of how date and time values work in spreadsheets.
#doubleunary option works, obviously! As she/he suggested, the option where A is blank should be first. You're missing some scenarios: first you have >1 and <-1, if you want those values to be considered you should add an equal: >=1 <=-1
And also the one in which it is the same date as Today () -- so you should set first if A2:A is empty, then if it is equal, and then if its greater or smaller:
=ArrayFormula((IFS(isblank(A2:A), "16",TODAY()=A2:A, "Is today",TODAY()-A2:A>=1, TODAY()-A2:A, TODAY()-A2:A<=-1, "0")))
try:
=INDEX(LAMBDA(a, t,
IF(a="", 16,
IF(t-a > 1, t-a-1,
IF(t-a = 0, t-a,
IF(t-a < -1, 0, )))))(A2:A, TODAY()))

In google sheets, grab last (by row) value in range that meets criteria

We have this dummy spreadsheet. In cell A15, we want the last value from A1:A13 that meets the criteria not equal to --, and not blank. A15 should then be 43, and B15 should be 23. Pretty much we just need the last non-blank, non "--" value in the range.
Presumably this can be done with a nasty long, nested ifelse type of statement, but we'd like to avoid that. Is there a better solution? Edit - added column C with integer range as I think this may be of some help?
try in A15:
=INDEX(INDIRECT("A"&MAX(ROW(A1:A13)*(A1:A13<>"")*(A1:A13<>"--"))))
alternative:
=QUERY(SORT(A1:A13, ROW(A1:A13), ),
"where Col1 is not null and Col1 <> '--' limit 1", )
Try this formula in A15 and drag to the right:
=MATCH(9^9,A1:A13,1)
You can enter this in A15 and drag to the right:
=regexextract(join("~",A1:A13),".*~(\d+)")
Edit: you can also do it with a single formula like this:
=regexextract(regexreplace(substitute(join("#",query(A1:B13,,9^9))&"#"," ","~"),"[~-]+#","#"),regexreplace(regexreplace(substitute(join("#",query(A1:B13,,9^9))&"#"," ","~"),"[~-]+#","#"),"~(\d+)#","~($1)#"))
You can adjust the two occurrences of A1:B13 to cover a bigger range.

How to extract the data on the right-hand side of the arrows in google sheet?

Hi everyone,
I want to extract the values after the arrows. If there is no arrow, then the expected output will be the value in the cell. I know that this can be done by using few functions (REPLACE or SUBSTITUTE) in another column, but I want to make this happen inside the QUERY function or wrap the QUERYfunction inside some functions so that I'm not require to have extra column to get the values after the arrow (if available). I'm not sure whether this can be achieved.
I tried to wrap the QUERY function inside a REPLACE function but this doesn't work.
The value in column F is the expected output that I want. Appreciate for any feedback or suggestion, thank you!
See if this helps
=INDEX(
REGEXEXTRACT(
QUERY(
IMPORTHTML(
"https://www.marketbeat.com/stocks/NYSE/NKE/price-target/", "table", 2),
"Select Col5 where Col5 is not null and Col1 > date
'"&TEXT(DATEVALUE(B2), "yyyy-mm-dd")&"'", 0),
"\$?[0-9.]+$")
)
Note that the output will be strings (text). To convert to number, change
"\$?[0-9.]+$")
to
"\$?[0-9.]+$")+0
and format the output column as 'valuta'.

Google Sheets Query Coalesce?

is there any query syntax that woks like coalesce in google sheets?
if i have a source like pict below
the result i want is only getting id and time if status is true, but the time is only exist in one col either in check column or report column
so the result would be like this...
I tired this but doesn't work
=QUERY(A1:D4, "SELECT A, COALESCE(B, C) WHERE D = TRUE")
any ideas or workarounds?
Thanks
try:
=ARRAYFORMULA(IFERROR(SPLIT(FLATTEN(QUERY(TRANSPOSE(
ARRAY_CONSTRAIN(IF(D2:D=TRUE, {A2:A, IF(B2:C="",,"×"&B2:C), D2:D}, ), 9^9,
COLUMNS(A:C))),, 9^9)), "×")))
A very short one just for the special case of 2 columns where you know that only one of them is populated and they are dates:
=ArrayFormula(to_date(if(D2:D,B2:B+C2:C,)))
Maybe the simplest formula which behaves like coalesce would be
=iferror(if(D2,hlookup(9^9,B2:C2,1,true),))
It's just a pull-down formula but will pick up the first non-blank column from a range of columns containing numbers or dates. If the columns are all blank, it returns blank.
You can take advantage of the either or situation and concatenate the 2 columns.
=filter({A2:A,concat(B2:B,C2:C)},D2:D)
Also see local array and filter
Add a column after Status call it Time (column E), whereas each formula follows this format (assuming your table starts at A3:E)
=if(A4="","",if(B4<>"",B4,C4))
Now query A3:E like so,
=query(A3:E,"Select A,E where D=TRUE")
you can use something like this:
=QUERY(transpose(B1:H1),"Select Col1 where Col1 is not null limit 1",0)
This transposes the row into a column, queries all non-null values from that column, and then set limit 1 to return the first value. So essentially you are selecting the leftmost non-empty value from your row.
I can't take full credit for this, I must have gotten it somewhere else... but it's in one of my sheets.

Import all values from a column if the header matches in Google Sheets

In Google Sheets is it possible to get all the values in the rows if a column header is the same?
So if I have
I want to query for "Type" and get the unique values as "Manhole, Overflow, Scour Manhole, Unknown"
If I transpose it I can do something like =VLOOKUP(B5,Sheet10!1:1000,2,False) and then have to figure out a way to get it to concatenate all values in subsequent fields of that row but it's better to avoid this.
You can use the following command
=textjoin(", ", 1, Unique(E2:E7))
Unique function returns unique value from the range and textjoin joins the returned value with your provided delimiter.
is it possible to get all the values in the rows if a column header is the same?
=UNIQUE(INDIRECT(ADDRESS(2, MATCH(E1, 1:1, 0), 4)&":"&
ADDRESS(ROWS(A2:A), MATCH(E1, 1:1, 0), 4)))

Resources