A2:
96610,80508,64406,48305
How do I extract the last value, in this case 48305?
There must be an easy solution, but I can't come up with it.
Another way would be something like
=regexextract(A2&"", "[^,]+$")
or, to convert the output to a number:
=regexextract(A2&"", "[^,]+$")+0
This formula did it:
=TRIM(RIGHT(SUBSTITUTE(A2,",",REPT(" ",500)),500))
Related
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))), ))
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
I wrote this formula in the spreadsheet: =if(match(AR$2,$A5:$E5,0),AR$2,"")
If there is no match, it's supposed to leave the cell blank, instead it gives #N/A. but if there is a match, it gives the value. Can anybody show me how to correct this? thanks.
You could use iferror
try something like:
=iferror(if(match(AR$2,$A5:$E5,0),AR$2),"")
so what Iam trying to do is:
Find a certain string in Spreadsheet1!A:A and give the value that is in B:B right next to the found value in A:A as an output.
My approach:
=VLOOKUP(B1;Spreadsheet1!A:A;Spreadsheet1!B:B)
The Problem:
VLOOKUP wont give strings back as a value. But I need the string for another formula. Is there any workaround, that does not include scripting?
Thank you!
Try this:
=VLOOKUP(B1;Spreadsheet1!A:B;2,False)
B1 should be the value that can be found in Spreadsheet1!A:A
I have a column XXX like this :
XXX
A
Aruin
Avolyn
B
Batracia
Buna
...
I would like to count a cell only if the string in the cell has a length > 1.
How to do that?
I'm trying :
COUNTIF(XXX1:XXX30, LEN(...) > 1)
But what should I write instead of ... ?
Thank you in advance.
For ranges that contain strings, I have used a formula like below, which counts any value that starts with one character (the ?) followed by 0 or more characters (the *). I haven't tested on ranges that contain numbers.
=COUNTIF(range,"=?*")
To do this in one cell, without needing to create a separate column or use arrayformula{}, you can use sumproduct.
=SUMPRODUCT(LEN(XXX1:XXX30)>1)
If you have an array of True/False values then you can use -- to force them to be converted to numeric values like this:
=SUMPRODUCT(--(LEN(XXX1:XXX30)>1))
Credit to #greg who posted this in the comments - I think it is arguably the best answer and should be displayed as such. Sumproduct is a powerful function that can often to be used to get around shortcomings in countif type formulae.
Create another list using an =ARRAYFORMULA(len(XXX1:XXX30)>1) and then do a COUNTIF based on that new list: =countif(XXY1:XXY30,true()).
A simple formula that works for my needs is =ROWS(FILTER(range,LEN(range)>X))
The Google Sheets criteria syntax seems inconsistent, because the expression that works fine with FILTER() gives an erroneous zero result with COUNTIF().
Here's a demo worksheet
Another approach is to use the QUERY function.
This way you can write a simple SQL like statement to achieve this.
For example:
=QUERY(XXX1:XXX30,"SELECT COUNT(X) WHERE X MATCHES '.{1,}'")
To explain the MATCHES criteria:
It is a regex that matches every cell that contains 1 or more characters.
The . operator matches any character.
The {1,} qualifies that you only want to match cells that have at 1 or more characters in them.
Here is a link to another SO question that describes this method.