I am using google sheets and would like to combine the text in cells of a column to a single cell separated by "OR" (with spaces on either side of the OR"
For example
**Column A**
John
Bob
Jim
Donald
would be combined in a single cell as "John OR Bob OR Jim OR Donald"
What formula in Google Sheets would I use to accomplish this?
try:
=JOIN(" OR ", A1:A4)
or:
=TEXTJOIN(" OR ", 1, A:A)
if you hit the limit try:
=ARRAYFORMULA(A1&" "&QUERY(IF(A2:A<>"", "OR "&A2:A, ),,999^99))
See if this works
=textjoin(" OR ", 1, A2:A)
Change range to suit.
Related
I have a Google Sheets file with the following data:
Column A
Column B
John
Apple
John
Orange
Mary
Apple
Mary
Kiwi
I would like to find all names that have Apple but not Orange, so in this case, John would not be flagged, but Mary would.
The flagging can be by way of highlighting every row that includes Mary via conditional formatting, or by only showing Mary in a pivot table report (as a single entry, or multiple entries equal to the number of lines).
I tried using pivot table and/or VLOOKUP but haven't figured out how to compare values from different rows.
To get a list of names that match your criteria, use filter() and match(), like this:
=filter(
A2:A,
B2:B = "Apple",
isna(
match(
A2:A,
iferror(filter(A2:A, B2:B = "Orange")),
0
)
)
)
This is a simplified version of my data.
I want to calculate the "Whole Tax" row Automatically. I mean I'm looking for any special google sheets formula that can search for those records that are equal to "TAX" and SUM on the values in corresponding month.
In google sheet QUERY() function is really faster and more scalable. You can use wildcard character to ignore leading and trailing spaces. Try below formula.
=SUM(QUERY($A$3:$D$16,"SELECT B WHERE LOWER(A) LIKE '%tax%'"))
On single go get sum of all columns. As per my screenshot put below formula to B17 cell.
=QUERY($A$3:$D$16,"SELECT SUM(B), SUM(C), SUM(D) WHERE LOWER(A) LIKE '%tax%' LABEL SUM(B) '', SUM(C) '', SUM(D) ''")
You should have posted a spreadsheet instead of an image to find out your locale. Try in B17, assuming TAX is not preceded by white spaces
=SUMPRODUCT($A$2:$A$16="TAX",B2:B16)
Consider placing sums at the top of each column so you can select cells using A2:A for rest of column.
Anyhow, use =SUMIF($A$1:$A$15, "*tax", B1:B15) for strings that end in tax, case-insensitive. The wildcard selectors are * for wildcard strings and ? for wildcard characters. Use ~ to escape.
Following on from Harun24HR, here is a more flexible formula in which you do not have to designate each column
=QUERY({A3:D16},"SELECT SUM(Col"&arrayformula(textjoin("),SUM(Col",,COLUMN(B3:D)))&") WHERE LOWER(Col1) LIKE '%tax%' LABEL SUM(Col"&arrayformula(textjoin(")'', SUM(Col",,COLUMN(B3:D)))&") '' ")
Is there any formula to extract a website from a cell value in google sheets
convert value from 1st column to as shown in 2nd column
You can use regex to retrieve string with pattern like website:
=REGEXEXTRACT(G1,"[a-zA-z]+\.[a-zA-z]+\.?[a-zA-z]+")
Reference:
REGEXEXTRACT
try:
=INDEX(TRIM(FLATTEN(QUERY(TRANSPOSE(
IFERROR(IF(ISURL(SPLIT(A1:A, " ")), SPLIT(A1:A, " "), ))),,9^9))))
We are using Google Sheets to track a list of about 60 people. We add and remove some each week. I am using functions like this to join them into a groups, =TEXTJOIN(", ", TRUE,$A$2:$A$15)
I would like to replace the $A$2:$A$15 part with something that would take 1/5th of the total list regardless of how long or short it becomes. Is this possible?
If you want to group only the first fifth:
=TEXTJOIN(", ", TRUE,$A$2:INDEX($A$2:$A,ROUNDUP(COUNTA(A2:A)/5)))
or if you want group all:
=TEXTJOIN(", ", TRUE,FILTER($A:$A,ROW($A:$A)>=(ROUNDUP(COUNTA($A:$A)/5)*(ROW()-2)+2),ROW($A:$A)<=(ROUNDUP(COUNTA($A:$A)/5)*(ROW()-1)+1)))
try:
=TEXTJOIN(", ", 1, INDIRECT("A2:A"&ROW(A2)-1+ROUNDDOWN(COUNTA(A2:A)/5)))
or:
=TEXTJOIN(", ", 1,
QUERY(A2:A, "where A is not null limit "&ROUNDDOWN(COUNTA(
QUERY(A2:A, "where A is not null", 0))/5), 0))
I'm trying to query a group of say fruits so I'm grouped these into a comma-separated cell and I want to query that cell but I don't get any results. When I just one value in that cell says Apple it wants a result. I thought using contains would allow me to do that in a query? If not are they better methods?
Table
A B
Bob Apple
May Orange
Simon Apple
Sam Pear
Tom Grape
Query
=IFERROR(QUERY('Sheet1'!$A2:$AB500, "select A,C,Y where D contains 'Staff' and (K='Y' or L='Y') and C contains '"&G7&"' ", 0),"None")
G7 contains 'Apple,Pear,Grape,Orange'
Try changing this part
C contains '"&G7&"'
to
C matches '"&SUBSTITUTE(G7, ",", "|")&"'
and see if that helps?
EDIT: if you have brackets in the range and in G7 try
=ArrayFormula(IFERROR(QUERY({A:C, regexreplace(B:B, "\(|\)",)}, "select Col1 where Col3 contains 'Team' and Col4 matches '"&SUBSTITUTE(REGEXREPLACE(D2, "\(|\)",), ",", "|")&"' ", 0),"None"))
and see if that works?