How can I change the range of countif() inside an arrayformula()? - google-sheets

I want to find duplicates that happen after the current row. I can find duplicates that happen anywhere with this formula but I don't want to flag the last occurrence of a particular value as being a duplicate.
=arrayformula(if(row(B:B) = 1, "Duplicate", if(not(isblank(A:A)), if(countif(A:A, A:A) > 1, "Yes", "No"), "")))
If I statically specify a starting cell in the lookup range it only finds duplicates after that spot. However I need to have the starting spot change based on the row I'm on.
=arrayformula(if(row(B:B) = 1, "Duplicate", if(not(isblank(A:A)), if(countif(A5:A, A:A) > 1, "Yes", "No"), "")))
I tried using indirect() and row() but it doesn't seem to update for each row.
=arrayformula(if(row(B:B) = 1, "Duplicate", if(not(isblank(A:A)), if(countif(indirect("A"&row(B:B)&":A"), A:A) > 1, "Yes", "No"), "")))

try:
={"Duplicate"; ARRAYFORMULA(IF(INDIRECT("A"&ROW()+1&":A")<>"",
IF(COUNTIF(INDIRECT("A"&ROW()+1&":A"), INDIRECT("A"&ROW()+1&":A")) > 1, "Yes", "No"), ))}
UPDATE:
={"Duplicate";
ARRAYFORMULA(IF(A2:A="",,
IF(COUNTIFS(A2:A, A2:A, ROW(A2:A), ">="&ROW(A2:A))>1, "Yes", "No")))}

Related

Multiple links to hyperlink string (Split and concatenate with ArrayFormula)

I'm trying to figure out how to make a formula to turn links in one cell into hyperlinks in another
From cell A1, A2 etc I'm trying to get cell B1, B2 etc using the Split and concatenate formulas. But it's not possible to process each link to make a "wrapper" and then wrap it back into one cell
A1
https://link.com/xxxxxx1, https://link.com/xxxxxx2, https://link.com/xxxxxx3
A2
https://link.com/xxxxxx1, https://link.com/xxxxxx2, https://link.com/xxxxxx3, https://link.com/xxxxxx4, https://link.com/xxxxxx5
B1
Button 1, Button 2, Button 3
B2
Button 1, Button 2, Button 3, Button 4, Button 5
https://docs.google.com/spreadsheets/d/1v8dYt6CIgwnlcc5HKJLNvuAcLZI0IKRTInsprs56hsU/edit?usp=sharing
try:
=INDEX(TEXTJOIN(", ", 1, "<a href="""&SPLIT(A1, ", ")&""">"&
"Name "&SEQUENCE(1, 3)&"</a>"))
arrayformula:
=INDEX(REGEXREPLACE(TRIM(FLATTEN(QUERY(TRANSPOSE(IF(A1:A="",,
IF(IFERROR(SPLIT(A1:A, ", "))="",,"<a href="""&SPLIT(A1:A, ", ")&""">"&
"Button "&SEQUENCE(1, 5)&"</a>,"))),,9^8))), ",$", ))

Is this possible? Check cell value if >0 move to next cell. Repeat until cell = 0, return last non-zero cell

I am trying to write a function that checks a cells value, and if that cell value is >0 it moves to the cell below, and checks that cell. Once it finds a cell that is not greater than zero then it posts the last cells value that was greater than zero.
i.e. C39 = 400 move to cell C40. C40 = 440 move to cell C41. C41 = 0, return cell value of C40.
Any insight would be greatly appreciated! :)
Try this:
=INDEX(
A:A,
MIN(
IFNA(MATCH(0, A:A, 0) - 1, ROWS(A:A)),
IFNA(MATCH(True, A:A = "", 0) - 1, ROWS(A:A))
)
)
This formula will return a cell with the minimal row number that is before the 1st 0, or it is before the first blank cell, or if there are no 0 and no blank cells it will return the last cell in a column.
Change A:A to C:C or whatever column you need.

Leave a cell blank until data is entered in different cell in Google Sheets

Can someone help me to type this formula: =IF($F5>0,I4/$F5,0)
inside this formula: =IF(F5="","",[I-want-to-type-it-here])
The first formula =IF($F5>0,I4/$F5,0) is to calculate the profit margin, and the second is to leave the cell empty until I enter data in a different cell.
try it like this:
=IFERROR(IF($F5>0, I4/$F5, 0), )
=IF(F5="", ,
IF($F5>0, I4/$F5, 0))
=IF(F5="", , IFERROR(IF($F5>0, I4/$F5, 0),
IF($F3>0, I3/$F3, 0)))

How do I get the row number of the last cell in a column,which is greater than zero?

I have tried with
=INDEX($K$2:K15,MATCH(TRUE,INDEX($K$2:K15>0,0),))
but this gives me the value of last cell in K row which is greater than zero.
How do I get the number of the row where last non-zero value lives?
Drag down
=INDEX(FILTER(ROW(K2:K15),K2:K15>0),1)
FILTER(ROW(K2:K15),K2:K15>0) is to get all rows where column values > 0. The index is to get the first one.
To get the last row number:
=INDEX(FILTER(ROW(K2:K15),K2:K15>0),COUNTIF(K2:K15,">0"))
This formula for row2: =INDEX(FILTER(ROW($K$2:K2),$K$2:K2>0),COUNTIF($K$2:K2,">0")). Drag down and see if it works. Gives #N/A if no rows were found
Single formula solution
=ARRAYFORMULA(VLOOKUP(ROW(K2:K16), QUERY(QUERY( { row(K2:K16) , IF(K2:K16>0,ROW(K2:K16),0) } , "select Col2, min(Col1) group by Col2"),"select Col2, Col1"), 2))
Paste in a cell from row2.

Google Spreadsheet, how to get a column filtering by a header value

To get a row from specific value in the first column is easy with FILTER function:
=FILTER(A:C, A:A = "ROW_89")
It will return the whole row which has a "ROW_89" in his column A
Now I would like to have the whole column which has a "COLUMN_12" in his row 1.
I'm trying:
=FILTER(A:C, 1:1 = "COLUMN_12")
But it is not working:
Error
FILTER has mismatched range sizes. Expected row count: 1. column count: 3. Actual row count: 1, column count: 26.
Strange thing indeed, but this works:
=FILTER(A:C, A1:C1 = "COLUMN_12")

Resources