In this sheet I'm trying to count different destination. It seems to be problematic when it comes to Æ, Ø and Å.
The formula
=COUNTA(B3:B12) & " travels to " & COUNTUNIQUE(ARRAYFORMULA(TRIM(IF(LEN(B3:B12);IFERROR(REGEXEXTRACT(LOWER(B3:B12);"^([\w\-]+)");B3:B12);))))&" differenct countries"
How can I make the formula accept these characters?
the TRIM(IF(LEN(B3:B14);IFERROR( is unnecessary in your formula.
the formula can be contracted to:
=COUNTA(B3:B14) & " travels to " & COUNTUNIQUE(ARRAYFORMULA(REGEXEXTRACT(LOWER(B3:B14);"\w+")))&" different countries"
EDIT:
if there will be any blanks in the data, then TRIM(IF(LEN(B3:B14); is unnecessary, and the formula can be contracted to:
=COUNTA(B3:B14) & " travels to " & COUNTUNIQUE(ARRAYFORMULA(IFERROR(REGEXEXTRACT(LOWER(B3:B14);"\w+");)))&" different countries"
EDIT 2:
in regards to your enquiry about countries with two word names, the following formula uses "[^,\d(]*" to find everything up to the first comma, number, or opening bracket, then uses TRIM to remove trailing spaces, so can return the full name.
=COUNTA(B3:B16) & " travels to " & COUNTUNIQUE(ARRAYFORMULA(IFERROR(TRIM(REGEXEXTRACT(LOWER(B3:B16);"[^,\d(]*"));)))&" different countries"
I have a Google Spreadsheet that record some author names like this:
A
A. Dagliati
A. Zambelli
A.H.M. ter Hofstede
Agnes Bates Koschmider
Ágnes Vathy-Fogarassy
Ahmed B. Najjar
Ala Norani
I want column B to receive some formula such that B will display the last name, a comma, and the first/middle name, like this:
A B
A. Dagliati Dagliati, A.
A. Zambelli Zambelli, A.
A.H.M. ter Hofstede Hofstede, A.H.M. ter
Agnes Bates Koschmider Koschmider, Agnes Bates
Ágnes Vathy-Fogarassy Vathy-Fogarassy, Ágnes
Ahmed B. Najjar Najjar, Ahmed B.
Ala Norani Norani, Ala
How can I do that?
Try this formula on row 2 of your sheet, with an empty column below it.
=ArrayFormula(IF(LEN(A2:A),REGEXEXTRACT(A2:A,".+\s(.+)") &", " & LEFT(A2:A,LEN(A2:A)-LEN(REGEXEXTRACT(A2:A,".+\s(.+)") )),""))
Image:
=CONCAT(RIGHT(A1,LEN(A1)-FIND("#",SUBSTITUTE(A1," ","#",LEN(A1)-LEN(SUBSTITUTE(A1," ",""))),1)), CONCAT(", ", LEFT(A1, FIND("#",SUBSTITUTE(A1," ","#",LEN(A1)-LEN(SUBSTITUTE(A1," ",""))),1))))
Basically, we are cutting off text from last index of " " (whitespace), append comma and do same from beginning.
Your best bet is probably to use regular expression replacement. It's not pretty, but it's the easiest way to search for the delimiter and perform the replacement using capture groups. I am still working on how to properly support cases where there is a single name like "A". For now it assumes it is the surname. Here is the formula:
=REGEXREPLACE(A1,"(.*?)([^ ]+)$", "$2, $1")
This function will search for any character non-greedily (.*? see the docs for RE2 here) which will allow the second capture group to find all the characters from the end of the string to the first delimiter which is a space in this case. Since we are using capture groups in the regular expression we can reference them in the replacement string using the $1 and $2 placeholders.
The output is as desired:
You could use a combination of:
SPLIT()
COLUMNS()
INDEX()
ARRAY_CONSTRAIN()
JOIN()
=JOIN(
", ",
INDEX(SPLIT(A2, " "), 1, COLUMNS(SPLIT(A2, " "))),
JOIN(" ", ARRAY_CONSTRAIN(SPLIT(A2, " "), 1, COLUMNS(SPLIT(A2, " "))-1))
)
Get the last name
Split up the name by space SPLIT(A2, " ")
Get the number of names COLUMNS(SPLIT(A2, " "))
Select on the last name INDEX(SPLIT(A2, " "), 1, COLUMNS(SPLIT(A2, " ")))
Get the other names
Split up the name by space again SPLIT(A2, " ")
Get all names except the last name ARRAY_CONSTRAIN(SPLIT(A2, " "), 1, COLUMNS(SPLIT(A2, " "))-1)
Join them back together JOIN(" ", ARRAY_CONSTRAIN(SPLIT(A2, " "), 1, COLUMNS(SPLIT(A2, " "))-1))
Join in desired order
JOIN(", ", LAST_NAME_FORMULA, OTHER_NAMES_FORMULA)
I'm using the formula below to try to generate a list, from another tab, in a Google Sheet. The aim is to pull out the last 25 times something was built.
I want the value for cell B2 to be something that a user can enter. The value is going to be a text value such as ABCDE1231535FGH.
=QUERY('Line 10'!A:F,"select B,C,F where C = '\"T(B2)"\' ORDER BY B DESC LIMIT 25",3)""
I am getting #ERROR! message back.
sample of what I am trying to do
Thanks for the help!
Based on your comment you can use the following syntax:
=QUERY(A10:F, "select B, C, F WHERE C = ' "& B2 &" ' ORDER BY B DESC LIMIT 25")
Notice the use of the single quotes ', double quotes " and ampersand & when referring a cell.
I would like to use a formula to capitalize just the first letter of an array of words. Sometimes the array might have just 1 word, and sometimes 2, 3, 4 or more words. The source is dynamic, so I need my formula to be flexible. I know about Proper(text), but that capitalizes every word.
For example, in cell A1 I might have the text "aidan is a good boy,"
or I might just have "hi,"
or maybe it will say, "drive in your own lane please!"
My formula over in B1 needs a result of "Aidan is a good boy,"; "Hi,"; or "Drive in your own lane please!"
I wish I could say, B1: =Proper(index(split(M1, " "), 1)) & " " & lower(index(split(M1, " "), *everything except 1*)), but I don't know how to fill in the *everything except 1* part of the formula.
Please try:
=REPLACE(A1,1,1,UPPER(left(A1)))
I'm using Google sheets to collect feedback.
Each session has a unique ID ( column A). I want to amalgamate feedback (Column B) that comes from the same session into a single cell in column C
It works with the formulas shown but each time someone submits feedback using google forms it creates a new row in the sheet and I have to manually copy and paste the formula into the newly created row. I solved this problem with other data i have been collecting by using an array formula.
However I can't figure out how to get this working as an array formula. Help!
A B C Formulas in column C
1
2 as1 ok ok =IF(A2<>A1,B2,C1 & "," & B2)
3 as1 short ok, short =IF(A3<>A2,B3,C2 & "," & B3)
4 as1 fun ok, short, fun =IF(A4<>A3,B4,C3 & "," & B4)
5 bg2 hard hard =IF(A5<>A4,B5,C4 & "," & B5)
6 bg2 easy hard, easy =IF(A6<>A5,B6,C5 & "," & B6)
Can anybody help?
=ARRAYFORMULA(IF(A3:A50<>A2:A49,B3:B50,C2:C49& "," & B3:B50))