I have a column of data that contains names, and the name always appears above a cell which contains parentheses. I'm able to run a query that shows those cells
=query(A:A,"Select * where A contains '('",)
but it's the cells directly preceding them that I need. Any help would be appreciated.
Try the following:
=index(hlookup("z",{"z";A:A},filter(row(A:A),regexmatch(A:A,"\(")),0))
You can replace the two occurrences of z with whatever you want.
The formula is self-explanatory if you are familiar with HLOOKUP and arrays.
try:
=QUERY(A:A; "skipping 2")
or:
=QUERY(A:A; "where not A contains '('")
Related
I am processing a list to output its items in chunks separated by blank rows as follows. But the result is not working when there are similar items, as shown with the arrows.
The formula I'm using is =query(filter(flatten({if(COUNTIFS($A$1:$A,$A$1:$A,ROW($A$1:$A),"<="&ROW($A$1:$A))=1," ",),A1:A}),flatten({if(COUNTIFS($A$1:$A,$A$1:$A,ROW($A$1:$A),"<="&ROW($A$1:$A))=1," ",),A1:A})<>""),"offset 1",0)
I need some help with it, to get the repeated chunks right too, so that the desired result is following. I've tried tweaking the COUNTIF conditions but am struggling.
Desired result
try:
=INDEX(LAMBDA(a, QUERY(FLATTEN(SPLIT(QUERY(IFERROR(
IF(a={""; a},"×"&a,"××"&a)),,9^9), "×")), "offset 1", ))
(A1:INDEX(A:A, MAX(ROW(A:A)*(A:A<>"")))))
When I opened it, there was no answer but here it goes all the same for you or another user 😉
It checks each row with the next one and adds a "|" when they differ, then joins all rows with that same symbol and split by that same symbol, resulting in empty rows between different values
=transpose (split(join("|",byrow(A1:A,lambda(each,if(each="","",SI(each=offset(each,1,0),each,each&"|"))))),"|",1,0))
Here's another solution:
=index(lambda(a,b,query(flatten(split(
a&if(a=b,,"❆ "),"❆")),"where Col1<>''"))
(filter(A:A,A:A<>""),{filter(A2:A,A2:A<>"");0}))
Essentially I am trying to find the sum in column A that corresponds to names distributed in the array to the right. Below is a picture of what I am trying to do and what my formula is as of now. Please let me know either how to modify my formula or how to restructure my data.
enter image description here
use:
=INDEX(TRANSPOSE(QUERY(SPLIT(FLATTEN(IF(B2:G14="",,B2:G14&"×"&A2:A14)), "×"),
"select Col1,sum(Col2) where Col2 is not null group by Col1 label sum(Col2)'Totals'")))
Here is a formula I came up with that can accomplish this:
=sum(filter($A$2:$A$11, arrayformula(REGEXmatch(ARRAYFORMULA((IF(ROW($A$2:$A$11)=1,"formulaTest",$B$2:$B$11 & $C$2:$C$11 & $D$2:$D$11 & $E$2:$E$11 & $F$2:$F$11))),B13))=TRUE))
This formula should be placed in the cell below Name1, next to Totals, and then copied across the row under each name. The cell references should be changed to match your sheet/needs. Anything with $ before it defines either the duration column, or each column that contains the names. The last cell reference (B13) is a reference to the cell that contains the name you are looking to total. A screenshot of an example of this is shown at the bottom of this answer.
In simple terms, this formula combines the names from each row into a single string (per row), searches for each name within that combined string, filters the duration value if there is a match, and then sums that value.
Hope this helped! Let me know if there is anything I should explain further or better clarify.
Here is a screenshot of and a link to my test spreadsheet. It makes the requirements very clear:
https://docs.google.com/spreadsheets/d/1rZr2zHaSkff9SFpwpx83_4TawruotA1jhOKqW6uYDz0/edit?usp=sharing
The formula I have come up with is very close to what I need, but "linkText" is a placeholder for the value of the array item. Here is my formula:
=if(A2="","","<a href='https://samplewebsite.com/search?q=" & trim(lower(substitute(A2,",","'>linkText</a>, <a href='https://samplewebsite.com/search?q="))) & "'>linkText</a>")
try:
=index(join(","&char(10), SUBSTITUTE($B$1, "linkText", split(A3, ","))))
Drag down to column.
Result:
First using SPLIT to split the strings between comma from the column A. Then using SUBSTITUTE to find the string "linkText" from the text in B1 and replace it with the strings from the returned strings from the split function. Then joining them all together.
NOTE: Just keep the reference string in a fixed cell in your sheet. <a href='https://samplewebsite.com/search?q=linkText'>linkText</a> to be used in the formula. As seen in above screenshot it is fixed in cell B1.
Alternate Solution using ArrayFormula:
You can also use it with arrayformula so you only have to put it in the first row and no need to drag down the formula to the column, it will automatically be expanded down just make sure to clear the cells below or it will throw an error.
=arrayformula(regexreplace(substitute(transpose(query(transpose(IF(IFERROR(SPLIT(A2:A, ","))<>"", "♦<a href='https://samplewebsite.com/search?q="&SPLIT(A2:A, ",")&"'>"&SPLIT(A2:A, ",")&"</a>", )),,9^9)), "♦", char(10)), "^\s", ""))
Result:
You may also have a look in below references for more information.
References:
SUBSTITUTE
SPLIT
JOIN
Comma separated list into matched columns pairings
In Google Sheets, I'm trying to indicate whether each cell in a specific column (the "Target Column") contains any of the words listed in a group of cells (the "Word Warehouse"), organized into different "Categories". If the word appears in the Word Warehouse, I would like the cell to spit out the category that it's listed under, e..
See attached sheet here: https://docs.google.com/spreadsheets/d/10jiicpOpplaURrF0UtTi9HM2TFP04-tinynpnFef2mE/edit#gid=0
Thanks in advance!
Try:
=INDEX($2:$2,1,MAX((ISNUMBER(SEARCH(IF(LEN($D$3:$F$7),$D$3:$F$7),A3))*COLUMN($D$3:$F$7))))
Alternatively, you can also try
=ArrayFormula(iferror(VLOOKUP(regexextract(proper(A2:A), textjoin("|", 1, D2:F)), split(flatten(D2:F&"_"&D1:F1),"_"), 2, 0)))
This formula allows for an array output, so dragging down is not necessary.
I have a sample Spreadsheet such as
And I want to import data from this spreadsheet to another spreadsheet, but after comparing some data, such as
My noob formula for the selected cell name in the second image:
=Query(ImportRange("URL of first spreadsheet","sheet!B:D"),"Select Col2 where Col2=A.....(what to add here? this column 'A' is not working for comparing the names)
My Approach:
I will compare the values from the import range with the existing column i.e. previousSpreadsheet.name.A=thisSpreadsheet.this_name.A and compare every name and SELECT values accordingly for the next three columns (in yellow). I hope I'm clear.
What should I add here? Is my approach right? If not, What are the alternatives to achieve this?
Thanks.
EDIT
(following OP's request)
Also, can I compare two cols with one? such as where LOWER(Col2)='"&LOWER(A2)&"' or '"&F2&"' or Col2=A2 || F2 something like this? for comparing two cols with one?
If you start using more than one names as variables, you may want to consider using other alternatives for the where clause, like matches
=Query(ImportRange("URL of first spreadsheet","sheet!B:D"),
"Select Col2 where Lower(Col2) matches'"&LOWER({A2&"|"&F2})&"'")
Original answer
Please use
=Query(ImportRange("URL of first spreadsheet","sheet!B:D"),"Select Col2 where Col2='"&A2&"'")
(where A2 is the name you need)
Pay notice to the syntax referring the cell: single quotes ' double quotes" ampersand & cell A2 and again &"'.
No spaces in between
try:
=ARRAYFORMULA(IFNA(VLOOKUP(A2:A, IMPORTRANGE("ID", "sheet!B:D"), {1,2,3}, 0)))