How to use the the column as identifier - google-sheets

I need to know which row of a certain column starts with the letter "O".
I tried for this the query function.
I try to achieve this with a QUERY on a this Column. But the first row of the Column doesn't have a particular name. My question is how can I use the Column as identifier in a 'where query'
In this example I need to know in which row of column
=QUERY(A4:A30;"where columnA start with 'O'")

As advised by #JPV:
=QUERY(A4:A30;"where A starts with 'O'")
However, with FILTER is shorter:
=filter(A4:A30;Left(A4:A30)="O")

Related

search for a number in another column

I have a large dataset, in it, Column A has an ID, and in Column B (texts with ID). I want Column C to display if the value exists or not if exists then leave the cell blank if not then show the number which should be in the cell.
The IDs will start from the first left (as shown in the screenshot).
I used the "=REGEXMATCH(B2:B(A2:A))" but it didn't work.
Thank you
Try the following formula-
=MAP(A2:A4,B2:B4,LAMBDA(x,y,IF(REGEXMATCH(y,x&"")=FALSE,X,"")))
To refer full column as input to MAP() function, use-
=MAP(A2:INDEX(A2:A,COUNTA(A2:A)),B2:INDEX(B2:B,COUNTA(A2:A)),LAMBDA(x,y,IF(REGEXMATCH(y,x&"")=FALSE,X,"")))

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.

Exclude current row from VLOOKUP?

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.

Google Sheets: How to have the same values in column 4 whenever there are duplicate values in column 1?

The image explains what I would like to achieve probably the best:
The table I would like to create, at the moment I have only first three columns:
I would like the "New Volume" to have the same values whenever the keyword repeats. At the moment I have the three first columns but cannot figure out with what formula I can create the "New Volume" column.
I would appreciate the help.
This is a vlookup job.
=vlookup(D3;$D$3:$E$8;2;false)
It searches D column for identifier (also in column D) and returns value from second column. When vlookup is set as false, will always return first found value.
To avoid copying down the formula, you can nest it with arrayformula:
=ArrayFormula(ifna(vlookup(D3:D;$D$3:$E;2;false)))
My solution is here:
https://docs.google.com/spreadsheets/d/1RpSsb6DmUs6lcPmZ1R6uPW-a3iWs9XEnSpc3b3XiihI/edit?usp=sharing

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.

Resources