Exclude current row from VLOOKUP? - google-sheets

When using VLookup is there a way to exclude the current row?
I'm trying to determine the following:
If two rows have the same value in column A,
check if they have the same value in column B.
It seems to me that
=exact(B2,vlookup(A2,A:C,2,FALSE))
should be able to do that, the only thing I can't figure out is how to ignore the current row so it doesn't compare itself to itself.
Just starting the vlookup range one row lower than the current row would work, except it's possible that the row with the matching value in column A is either above or below the current row.
Thanks!

If two rows have the same value in column A,
check if they have the same value in column B.
use:
=ARRAYFORMULA(IF(A2:A&B2:B="",,COUNTIFS(
FLATTEN(QUERY(TRANSPOSE(IFERROR(CODE(REGEXEXTRACT(A2:A&B2:B,
REPT("(.)", LEN(A2:A&B2:B)))))),,9^9)),
FLATTEN(QUERY(TRANSPOSE(IFERROR(CODE(REGEXEXTRACT(A2:A&B2:B,
REPT("(.)", LEN(A2:A&B2:B)))))),,9^9)))>1))

Use COUNTIFS instead:
=COUNTIFS(A:A,A2,B:B,B2)>1

You can use the range you want to check for the vlookup
So you can use this query: =exact(A1,vlookup(A1,A1:B4,2,FALSE))
Note: A1:B4 is the range for the vlookup.
For more about vlookup you can check: Link.

Related

Google Sheet: Exclude a row from counting based on value of another column

I have a Google sheet as follows:
I am counting all "yes" in column B based on the formula =COUNTIF(B2:B6,"Yes").
However, I would like to exclude row 5 based on the value "EXCLUDE" in column A.
How can I perform such filtering?
you can try either:
=COUNTIFS(B2:B6,"Yes",A2:A6,"<>"&"EXCLUDE")
OR
=COUNTA(IFNA(FILTER(B:B,B:B="yes",A:A<>"EXCLUDE")))
try:
=SUMPRODUCT(B2:B6="yes"; A2:A6<>"exclude")

How to find a value from a range of cells and place at a specific in google sheet

Suppose I have only one value anywhere at the cell range C2:Z2, I want that value at B2. What can I do?
I need this solution for all the rows bellow this also. The value might at C:C column at one row, at H:H column at another, that means it is dispersed at the range but there will be only one value at the range in a row.
Place this formula in B2:
=ARRAYFORMULA(TRIM(TRANSPOSE(QUERY(TRANSPOSE(C2:Z), , COLUMNS(C2:Z)))))
The formula above works for any type of values.
If your values are numbers then a simpler formula could be used (MMULT does row wise sum here):
=MMULT(
ARRAYFORMULA(--(C2:Z)),
SEQUENCE(COLUMNS(C2:Z), 1, 1, 0)
)
You can use FILTER()
=FILTER(C2:Z2, NOT(ISBLANK(C2:Z2)))
Reference:
FILTER()
if there will be only one value in the row then a simple sum function will do the job for you. put this in B2 ..
=sum(C2:Z2)

Is it possible to transpose a column of text values into a single row without duplicates based on an if statement?

E.g. I have the following sheet and formula, but I only want to transpose the data if it contains a specific month, specified in A2.
try:
=TRANSPOSE(UNIQUE(FILTER(A5:A; B5:B=A2)))
You can use a query for that.
=TRANSPOSE(QUERY(A5:C, "select A where month(B)+2="&MONTH(A2)&""))
The reason we add +1 is because months in a query start from 0

Flag Non-Unique Rows (After the First Instance)

I have a Google Sheets spreadsheet where I am needing to create an array formula that will determine uniqueness and flag non-unique rows. I need it to flag non-unique rows but only the second & subsequent duplicates (the first duplicate will not be flagged and should say "Unique"). I have this formula but it includes the first duplicate.
={"Unique";
ArrayFormula(
IFS(
$C$2:$C="","",
$C$2:$C<>"", IF(COUNTIF($A$2:$A,$A$2:$A)>1,"Not Unique","Unique")
)
)
}
How can I modify this formula to not flag the first instance of a non-unique row?
Your formula looks very strange to me, perhaps try:
=ArrayFormula(IF($C$2:$C="","",IF(COUNTIF($A$2:$A$100,A2:A100)=1,"Unique","Not Unique")))
It'll need a Row number helper column:
J1 =ARRAYFORMULA(row(A:A))
Then, the magic formula, where 10 is the column ID for the helper column
=ARRAYFORMULA(if(VLOOKUP(A:A,A:J,10,false)=row(A:A),"Unique","Not Unique"))
The vlookup returns the first row number in the helper column where the value in A:A is found and compares it to the currently calculated row.

Arrayformula sum one column until this row

I'm trying to make an array formula which sums up all the rows until this row.
For clarification column a will be the input and column b would be the output. I'm looking for a way to do this with an arrayformula.
a1:1 b1:1a2:2 b2:3a3:5 b3:8a4:3 b4:11
I tried to use =ARRAYFORMULA(SUM(INDIRECT("F1:"&ADDRESS(ROW(),COLUMN(F2:F))))) but this doesn't work.
How about
=arrayformula(sumif(row(A1:A4),"<="&row(A1:A4),A1:A4))
The sumif is evaluated separately for each value in the criteria part so:
In the first row of the output array you have
=sumif(row(A1:A4),"<=1",A1:A4)
giving you just the first row of column A.
In the second row of the output array you have
=sumif(row(A1:A4),"<=2",A1:A4)
giving you the sum of the first 2 rows and so on.
Since OP changed the question with a clarification, A different answer is submitted below:
B1:
=ARRAYFORMULA(MMULT(transpose(A1:A5)*--IF(row(1:5),COLUMN(A:E)<=row(1:5)),ROW(1:5)^0))

Resources