I get Formula parse error with all formulas - google-sheets

I want to use basic functions in google spredsheets (which works just fine in excel) but I get
"Formula parse error"
on all of them.
For example, there is table where date is in one column, and according value in second. I want to extract, into another sheet, value from the 1st week to the first row, value from the week +1 to second etc....
=OFFSET(A2, 1, 0)
=OFFSET(A2, 1, 0, 1, 1)
I get Parse formula error. It is happenning also with other formulas, LEFT, CONCATENATE etc... Is there anything wrong in the way I write them?

This might be a locale issue. Some locales use a comma as argument separators, others (e.g. some European countries) use semi-colons (;).
So maybe try changing your comma's into semi-colons?

Related

How to get Google Sheets to recognize I'm entering time in MM:SS?

I am trying to record the time it takes for a number of things to occur, and can't seem to get Google Sheets to understand my input. I want to be able to type something like "26:30" into a cell, and have the spreadsheet understand that this means 26 minutes and 30 seconds, and then be able to use that number in formulas, e.g. to return the shortest of a series of times, or the difference between two times.
Also, the vast majority of the numbers I type in will be under an hour, so I don't want to have to type in something like "0:26:30" every time, just for it to understand that I mean 26 minutes, not 26 hours. However for the rare occasions where something is longer than an hour, I want to be able to be able to type something like "1:10:23" and not "70:23".
If possible, I would rather achieve this through directly formatting the cell I type the time into, rather than enter it in one format and have it converted in a separate cell via a formula.
Is there a way to do this that meets all of these goals?
google sheets is not designed in such a way. if you want to type in 26:30 then the best course of action is as follows:
convert cells to Plain Text, type in your duration, and account for your rules within formulae. to convert a text string into a value for the sake of calculation you can use the following principle
=ARRAYFORMULA(IFERROR(IF(REGEXMATCH(A1:A, ":\d+:"), A1:A*1, ("0:"&A1:A)*1)))
few examples:
=ARRAYFORMULA(TEXT(AVERAGE(IF(REGEXMATCH(A1:A2, ":\d+:"),
A1:A2*1, ("0:"&A1:A2)*1)), "[m]:ss"))
=ARRAYFORMULA(TEXT(SUM(IF(REGEXMATCH(A1:A2, ":\d+:"),
A1:A2*1, ("0:"&A1:A2)*1)), "[h]:mm:ss"))
=ARRAYFORMULA(TEXT(IF(REGEXMATCH(A2, ":\d+:"), A2*1, ("0:"&A2)*1)-
IF(REGEXMATCH(A1, ":\d+:"), A1*1, ("0:"&A1)*1), "[m]:ss"))
At this point in time there doesn't seem to be a way to directly format a cell such that Google Sheets recognises it as MM:SS instead of HH:MM, so I've had to go with formulas instead. Sharing the solution I used below.
I set it up so that the user entered the time into cell A1 in the form MM:SS or H:MM:SS and I formatted this cell as plain text, then had a second cell formatted as 'time duration' where it converted the input of A1 using the following formula:
=time(left(A1,if(len(A1)<6,"",len(A1)-6)),right(left(A1,len(A1)-3),2),right(A1,2))
To break this down:
It starts by assuming the contents of A1 is a text string with 5 or more characters in the form MM:SS or H:MM:SS or HH:MM:SS. It does not include any sort of error handling to check this is true.
The time(X,Y,Z) part of the formula converts different inputs into hours, minutes and seconds, respectively, and produces a number in the format HH:MM:SS, which is recognised as a time, and can therefore be used in formulas. Note that the cell has to be formatted as 'time duration' to display correctly.
In the above, Z is right(A1,2) which extracts the last two characters of A1, i.e. the SS part of the input. These end up as seconds.
Likewise, Y is right(left(A1,len(A1)-3),2) which extracts the 4th and 5th characters from the right of the text string of A1, i.e. the MM part of the input, after the :. This number is then recognised as minutes.
Finally, X is left(A1,if(len(A1)<6,"",len(A1)-6)), which basically says "if A1 is less than 6 characters then it must not have hours, so leave blank, otherwise extract out all characters except the last 6", i.e. the HH part of the input, if it exists. This number (which may or may not be 0) is then recognised as hours.

Trouble searching combined ranges in HLOOKUP

I'm having trouble with HLOOKUP in Google Sheets. I'm trying to determine whether an inputted word is unique in a row and for this reason my formula searches combined ranges [that exclude itself] within an HLOOKUP. This is the formula I'm using [in cell E4]:
=HLOOKUP(E2, {B2:D3;F2:M3}, 2, false)
Doubtless, there's something I'm doing wrong, because I keep getting this error:
"HLOOKUP evaluates to an out-of-bounds range"
What I want to happen is that it will find a match for "ice" in the range to the left [B2:D3] and the range to the right [F2:M3]...
Confusingly, the equivalent formula works for VLOOKUP, but not HLOOKUP. I've found it also works in HLOOKUP if I search for a single range [ie B2:D3] and not a combined range.
So I'm a bit stuck. The combined range search works fine in VLOOKUP, but perhaps I need to write it differently for HLOOKUP?
Any help would be greatly appreciated.
instead of this:
=HLOOKUP(E2, {B2:D3; F2:M3}, 2, 0)
try this:
=HLOOKUP(E2, {B2:D3, F2:M3}, 2, 0)
For identifying duplicates conditional formatting might suit you. Select all relevant columns : Format > Conditional formatting..., Format cells if... Custom formula is and:
=countif(1:1,A1)>1
with formatting of your choice.
This should format all instances of any value repeated in its row.

Google spreadsheets conditional formatting if text contains numbers

I have a sheet containing my weekly schedule. Only school cells have a room number in it, so how do I format the cells to color only the ones that contain a number.
note: Actually, the room number is a number in range(A:E) followed by a three digits number in range(000:499). Ex.:(A433, B166, D254)
I tried: Text contains"(A:F)(000:444)" but it didn't work.
EDIT:
For some reason, "=REGEXMATCH(B2, "[A-F][0-9]{3}")" worked. Could anyone tell me why? I tried replacing B2 by B1, but then it didn't work. Does it have anything to do with the fact that B1 is a weekday, and so does not contain REGEXP(B1,"[A-F][0-9]{3}) returned false.
What seemed more logical to me was "=REGEXMATCH(B2:F22, "[A-F][0-9]{3}")" To apply this function in range B2 to F22. What am I missing here?
In order to match patterns, you'll need to use regular expressions. Since the standard Conditional Formatting options don't include regular expressions, you'll need to choose "Custom formula is" and then use REGEXMATCH, which returns a Boolean value.
If you really want to look for the specific room number format you mentioned, then you would use the formula:
=REGEXMATCH(A1, "[A-E][0-9]{3}")
But if you just want to look for any numbers, you can use
=REGEXMATCH(A1, "[0-9]+")
In both cases, the text you're checking is in cell A1
You might try Conditional Formatting with a custom formula rule of the type:
=if(isnumber(A1),1,regexmatch(A1,"\d"))
The above was an attempt to respond to:
Google spreadsheets conditional formatting if text contains numbers
A more particular fit for the stated room number style would be:
=REGEXMATCH(A1,"[A-F]\d\d\d")
where the first character is any of the first six letters of the alphabet, if capitalised, followed by three instances of any number.

Add title row with ARRAYFORMULA in Google Sheets

I watched a tutorial where the author uses an IF statement along with the ARRAYFORMULA function to add a title row to a column of data. Links are given to the docs; however, for an example of how to use ARRAYFORMULA see this answer.
An example can be seen below:
I was able to populate the C column by placing the following formula in C1:
=ARRAYFORMULA(if(row(A:A) = 1, "spent", B:B - A:A))
I'm confused about the syntax. I understand that X:X references the entire X column but I don't understand how it's being used to check if we're at cell A1 in one context and then being used to apply mass formulas in another context.
How does the above line work?
Can you illustrate with some examples?
It sounds to me that the information you learned led you to expect that row(A:A)=1 translates to row A1?
It works a little different than that, the syntax as your using it now, is basically saying if any row in A:A has a value of 1, then write "spent" else subtract B-A
My suggestion:
use a literal array to make your header, then use the if(arrayformula) to only populate rows with values, for aesthetics:
Example:
={"Spent";arrayformula(if(isnumber(A2:A),B2:B-A2:A,))}
Explanation:
The {} allow you to build a literal array, and using a semicolon instead of a comma allows you to stack your cells vertically, following that we check if there is a value in column A, if so, subtract A from B, else leave it blank.
why not just put the column title directly on the first row cell, and start the array formula from the 2nd row, using the A2:A, B2:B syntax?
If something does not have to be in a formula, better put it directly on the cell - simpler for others to understand what's going on, and the formula will be simpler.
If you put the array formula in line 2, and someone sorts the data, then the arrayformula will move. If it is in the header line, this is less likely to happen.
You can also use the IFS function to achieve a similar effect to the array,
=arrayformula(ifs(row(A1:A)=1,"Spent",A1:A="",,True,B1:B-A1:A)
Here the first condition checks the row number, and if it is row ONE, then inserts a Column Header.
The Second condition - A1:A="",, - ensures that blank lines are ignored.
The Third condition True (ELSE) performs the calculation.
This method also allows for different calculations to performed on different rows depending on requirements.

Get data between number two and three delimiter

I have a large list of people where each person has a line like this.
Bill Gates, IT Manager, Microsoft, <https://www.linkedin.com/in/williamhgates>
I want to extract the company name in a specific cell. In this example, it would be Microsoft, which is between the second and third delimiters (in this case, the delimiter is ", "). How can I do this?
Right now I'm using the split method (=SPLIT(A2, ", ",false)). But it gives me four different cells with information. I would like a command only to output the company in one cell. Can anyone help? I have tried different things, but I can't seem to find anything that works.
Maybe some regex can do it, but I'm not into regex.
Short answer
Use INDEX and SPLIT to get the value between two separators. Example
=INDEX(SPLIT(A1,", ",FALSE),2)
Explation
SPLIT returns an 1 x n array.
The first argument of INDEX could be a range or an array.
The second and third arguments of INDEX are optional. If the first parameter is an array that has only one row or one column, it will assume that the second argument corresponds to the larger side of the array, so there is no need to use the third argument.
A bit nasty, but this formula works, assuming data in cell D3.
=MID(D3,FIND(",",D3,FIND(",",D3)+1)+2,FIND(",",D3,FIND(",",D3,FIND(",",D3)+1)+1)-FIND(",",D3,FIND(",",D3)+1)-2)
Broken down, this is what it does:
Take the Mid point of D3 =MID(D3
starting two characters after the 2nd comma FIND(",",D3,FIND(",",D3)+1)+2
and the number of characters between the 2nd and 3rd comma, excluding spaces FIND(",",D3,FIND(",",D3,FIND(",",D3)+1)+1)-FIND(",",D3,FIND(",",D3)+1)-2)
I'll add my favourite ArratFormula, which you could use to expand list automatically without draggind formula down. Assumptions:
you have list with data in range "A1:A20"
all data have same sintax "...,Company Name, <..."
In this case you could use Arrayformula, pasted in cell B1:
=ArrayFormula(REGEXEXTRACT(A1:A20,", ([^,]+), <"))
If your data doest's always look like "...,Company Name, <..." or you wish to get different ounput, use this formula in cell B1:
=QUERY(QUERY(TRANSPOSE(SPLIT(JOIN(", ",A1:A20),", ",0)),"offset 2"),"skipping 4")
in this formula:
change 2 in offset 2 to 0, 1, 2, 3 to get name, position, company, link
in skipping 4 4 is a number of items.
Number of items can be counted by formula:
=len(A1)-len(SUBSTITUTE(A1,",",""))+1
and final formula is:
=QUERY(QUERY(TRANSPOSE(SPLIT(JOIN(", ",A1:A20),", ",0)),"offset 2"),
"skipping "&len(A1)-len(SUBSTITUTE(A1,",",""))+1)

Resources