Google Spreadsheets: number becomes date after SPLIT - google-sheets

I have this text in A1: 18.03 x 13.76 x 1.48 cm
Then I have this formula: =SPLIT(A1;"x")
Problem is that the output is set with a DATE format.
I mean that 18.8 becomes 18/03/2021 instead of 18.8.
I need the output to have an number format instead of date.
How can I sort this out?

You can use the following
=SPLIT(REGEXREPLACE(B1;"\.";",");"x")
Or even
=SPLIT(REGEXREPLACE(B1;"\.";",");" x")
Functions used:
REGEXREPLACE
SPLIT

Try
=arrayformula(to_text(split(A1;"x")))

try:
=INDEX(TEXT(SPLIT(A1; "x"); "#"))
or use internal formatting and set it to Number

Related

Repeating a value on the basis of count provided in another cell - Google Sheets

I'm trying to write a formula where I can generate a number n number of times where n can be the input provided by the user.
=ARRAYFORMULA(TRIM(TRANSPOSE(SPLIT(QUERY(
REPT($D2&",", $E2), ), ","))))
Ideal output
Here D2 is the value to be repeated and E2 is the number of times.
So instead of manually using this formula after each last repeated value to generate the next set of repeated values, I want to print the values in one go. I'll be really grateful, if anyone could please provide a way around to do the same. Thanks in advance.
Try this
=ARRAY_CONSTRAIN(arrayformula(query(flatten(split(rept("|"&D2:D,E2:E),"|")),"select * where Col1 is not null")),SUM(E2:E),1)
explanation
the core of the formula is
=arrayformula(iferror(split(rept("|"&D2:D,E2:E),"|")))
then, apply flatten with a limitation of rows (ARRAY_CONSTRAIN) equal to the sum of column E, and query only the rows that are not null
Try the below formula:
=ARRAYFORMULA(TRIM(TRANSPOSE(SPLIT(QUERY(
REPT(D2:D&",", E2:E), ,999^99), ","))))

What is the easiest and most accurate way to average feet/inches?

Using the format #'##, what would be the best way to average values using a formula?
For example: if I have the following values -
The average of these heights should return 5'01. What would be the best way to achieve this using a formula? Thank you!
try:
=INDEX(JOIN("'", TEXT({"", "0."}&SPLIT(AVERAGE(QUERY(QUERY(SPLIT(A1:A3, "'"),
"select Col1+Col2/12"), "offset 1", 0)), ".")*{1, 12}, {"0", "0#"})))
Given your post data, which runs A1:A3 (and I'm assuming further down than Row 3):
=ArrayFormula(INT(AVERAGE(FILTER({VALUE(REGEXEXTRACT(A:A,"\d+"))+VALUE(REGEXEXTRACT(A:A,"\d+$"))/12},A:A<>"")))&"'"&TEXT(ROUND(MOD(AVERAGE(FILTER({VALUE(REGEXEXTRACT(A:A,"\d+"))+VALUE(REGEXEXTRACT(A:A,"\d+$"))/12},A:A<>"")),1)*12),"00"))
In summary, REGEXEXTRACT is used to separate the left and right portions of the original data. VALUE converts them from strings to numbers. /12 and *12 do the conversion from inches to decimal and back to inches. The ampersand (&) symbols are used to concatenated the final INTeger portion, the feet symbol (') and the converted decimal-to-inches value. TEXT assures that the final result is in the format 00.
I've come up with a formula that might solve your problem but it is a bit long.
=ROUND(ARRAYFORMULA(AVERAGE((REGEXEXTRACT(A1:A3, "(\d)'\d+")*12)+REGEXEXTRACT(A1:A3, "\d'(\d+)")))/12)&"'"&MOD(ARRAYFORMULA(AVERAGE((REGEXEXTRACT(A1:A3, "(\d)'\d+")*12)+REGEXEXTRACT(A1:A3, "\d'(\d+)"))),12)
What the formula does is it calculates the values of A1:A3 into inches and gets the average before converting it again into feet'inches format. Please see result below.

Google Sheets: Sum if value is round number

I'm sure there's a pretty simple solution, but I cant' get to it.
I'm trying to sum a list of numbers, but only the values that are round numbers/whole integers.
Eg column A:
1
1.5
3
2.4
2
sum of the whole numbers
1 + 3 + 2 = 6
Any hint?
Let's suppose your numbers list begins in A2 and runs downward (i.e., A2:A). You can use this:
=SUM(FILTER(A2:A,A2:A=INT(A2:A)))
In plain English, this reads as follows: "Sum only those numbers in A2:A where the original value is the same as the integer-only portion of that value."
Try:
=sumproduct((A1:A5)*(A1:A5=int(A1:A5)))
this will also work in Excel
use dot detection:
=INDEX(SUM(IF(REGEXMATCH(""&A:A, "\."),,A:A)))
Another solution, you can use SEARCH to search for the decimal point:
=SUM(A1:A)-SUM(FILTER(A1:A,SEARCH(".",TO_TEXT(A1:A))))
or =SUM(FILTER(A1:A,NOT(ISNUMBER(SEARCH(".",A1:A)))))
as JvdV mentioned in his comment.
Either try QUERY():
=SUM(QUERY(A:A,"where A matches '\d+'"))
Or FILTER():
=SUM(FILTER(A:A,MOD(A:A,1)=0))
Note: This 1st option makes use of the possibility to use a regular expression inside the "where" clause of QUERY(). Use =SUM(QUERY(A:A,"where A matches '-?\d+'")) if you want to account for positive and negative integers.

Formula that will skip one column when calculating SUM() or similar functions

I'd like to run a =SUM(A1:G1), but always skip one column, regardless if it has value or not.
In this case, it should calculate A1+C1+E1+G1.
Is there another function I could append to SUM() or other similar functions as SUM in order to skip one column?
Thank you!
Using the following method you can calculate any number of alternate columns, without the need of manual +
Suppose your data is in second row onwards, use this formula
=SUMPRODUCT(A2:G2, MOD(COLUMN(A2:G2),2))
Simply a sumproduct of cell values and a array of {1,0,1,0,1...}
Another slight variation
=SUMPRODUCT(A2:G2*ISODD(COLUMN(A2:G2)))
But if the even columns contain letters instead of numbers this will give an error, so you can use instead
=SUMPRODUCT(N(+A1:G1)*ISODD(COLUMN(A1:G1)))
Comparing #AnilGoyal's answer, this works as well
=SUMPRODUCT(A1:G1,--ISODD(COLUMN(A1:G1)))
You can use:
=SUM(INDEX(A1:G1,N(IF(1,{1,3,5,7}))))
Or with Excel O365:
=SUM(INDEX(A1:G1,{1,3,5,7}))
A bit more of a general solution:
=SUMPRODUCT(MOD(COLUMN(A1:G1),2)*A1:G1)
Or with Excel O365:
=SUM(MOD(COLUMN(A1:G1),2)*A1:G1)
Or even:
=SUM(INDEX(1:1,SEQUENCE(4,,1,2)))
Since you included Google-Sheets, I'll throw in an option using QUERY():
=SUM(QUERY(TRANSPOSE(1:1),"Select * skipping 2"))
Maybe a bit more verbose, but very understandable IMO.
Consider something of the format:
=SUM(A1:G1)-INDEX(A1:G1,2)
The 2 in the formula means remove the 2nd item in the part of the row. (so the 999 is dropped)
So the formula =SUM(BZ10:ZZ10)-INDEX(BZ10:ZZ10,2) drops CA10 from the sum, etc.(a similar formula can be constructed for columns)
google sheets:
=INDEX(MMULT(N(A1:H3), 1*ISODD(SEQUENCE(COLUMNS(A:H)))))
=INDEX(IF(ISODD(COLUMN(A:H)), TRANSPOSE(MMULT(TRANSPOSE(
IFERROR(A1:H3*ISODD(COLUMN(A:H)), 0)), 1^ROW(A1:A3))), ))

IsDate ArrayFormula

Have just noticed isDate does not work in arrayformula.
Case
Want to filter all values if dates:
Used the formula:
=FILTER(data,ISDATE(data))
Expected result:
8/28/2018
Got:
#N/A
Question
Why? Other checks work in filter (isNumber, isText, isErr).
Workarounds?
Please try:
=ARRAYFORMULA(ISDATE_STRICT(A1:A11))
The function is currently not documented.
🧐: ISDATE_STRICT wont let date&time format, dates only
Do not know the reason, still curious.
Workaround: =FILTER(data,IFERROR(DATEVALUE(data))) was found here
Note: Workaround will NOT work for dates formatted as:
dd.mm.yyyy
You may use a duck-typed workaround:
=FILTER(data,REGEXMATCH(MID(data,7,4),"20\d{2}"))
Will check if formatted date has a 20XX year string inside.
Now you can convert any formula to arrayformula:
=BYROW(A2:A12,LAMBDA(r,ISDATE(r)))
A workaround that could work depending on what you're trying to do as far as Arrayformula is concerned
=ARRAYFORUMLA(ISNUMBER(VALUE(data)))
VALUE can turn the time into a number
ISNUMBER checks if it's a number
ISNUMBER works fine within ARRAYFORMULA

Resources