How to lookup and sum with Google Sheets - google-sheets

So I have this spreadsheet
And I want to essentially grab the value to the right of the value.
So for example, if I look for x, I want to get the values of E9, and E15. So far this is my query:
=LOOKUP(D23 , $D$5:$E$16 , $E$5:$E$16 , FALSE)
But all I'm getting is:
Error
Formula parse error
Any idea what I'm doing wrong?
EDIT:
I thought I might be making a mistake, since I forgot I'd have to SUM, but after changing the key to tax it still doesn't work
I tried both LOOKUP and VLOOKUP, same problem in each
I also tried smth I found in a tutorial, but no luck
=VLOOKUP(D23 , $D$5:$E$16 , 2 , FALSE)
TO FUTURE SEARCHERS:
To figure out which "breaker" you need (, of ;), take a close look at the formula help. It's the blue question mark next to the fx

Try using SUMIF (Documentation) instead of LOOKUP or VLOOKUP.
Like so:
=SUMIF(D5:D16;"tax";E5:E16)
Also, as you are using a Polish "Locale", you should use ; instead of ,.
Reasoning: whether you have to use , or ; depends on the "Locale" of the spreadsheet, under File –> Spreadsheet Settings. For example, a US or UK "Locale" would use the former (,) while a Hungarian or Polish "Locale" would use the latter (;)

You should use SUMIF
=sumif($D$5:$D$16;"x";$E$5:$E$16)

Related

How to check multiple ranges for different values in Google Sheets

I'm trying to search 3 different ranges in a tab, and trying to display Yes if all three values (email address, name, x) are found in those ranges. Basically, trying to have the formula confirm that yes, all three of those inputs are somewhere in those ranges (order doesn't matter).
Maybe I should use query or regexmatch or something? Any help is appreciated
Tried this formula:
=IF(AND('Helper Calculations'!$I:$I=$A$1,'Helper Calculations'!$J:$J=L$1,'Helper Calculations'!$L:$L=$A2),"Yes","No")
Was expecting that if the search term in each of those cells ($A$1, L$1, $A2) is found somewhere in the corresponding ranges, then it would say Yes
You can try with this (you can change the use of asterisks by wrapping in AND:
=IF(COUNTIF('Helper Calculations'!$I:$I,$A$1)*COUNTIF('Helper Calculations'!$J:$J,L$1)*COUNTIF('Helper Calculations'!$L:$L=$A2),"YES,"NO")
try:
=INDEX(IF(('Helper Calculations'!I:I=A1)*
('Helper Calculations'!J:J=L1)*
('Helper Calculations'!L:L=A2), "Yes", "No"))
Took a bit more work than I expected, but I got this working. I needed to verify that all 3 values were correct in a single row (must all be correct on that one row, can't find the correct values on multiple rows).
In order to do that, I needed to use array formula, and then decided to use index match and concatenate for the 3 values.
Process described here: https://www.ablebits.com/office-addins-blog/google-sheets-index-match/
correct formula: =IF(ArrayFormula(INDEX('Helper Calculations'!$I:$I,MATCH(CONCATENATE($A$1,L$1,$A2),'Helper Calculations'!$I:$I&'Helper Calculations'!$J:$J&'Helper Calculations'!$L:$L, 0),))=$A$1,"Y"))

google sheets : Formula works differently than usual

Hi today i got a document shared by my friends. I've just found out that this document/spreadsheet doesn't work as normally. Some formula just doesn't work here.
for example , normally if i use :
={1,2,3}
it should normally create a row with 3 columns (3 cells each contains 1,2,3 respectively).
But in this document , i got : "formula parse error"
Also found out that when i try to use some formulas , for example the filter(), the help/documentation shows something really different.Pls check my screenshot, normally it uses comma (,) separator while this document using semicolon (;). I'm confused what is wrong ? I'm suspecting that this maybe about google sheet versioning. Am i correct ? or something else ?
If yes, how can i convert this old version document into the latest one ?
Thanks.
your sheet is not US-based, therefore you need to use:
={1\2\3}
ENGLISH SHEETS NON-ENGLISH SHEETS
ROW ARRAY , \
COLUMN ARRAY ; ;
FX ARGUMENT SEPARATOR , ;
language of the spreadsheet can be found in the settings:

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))), ))

Find Unique in google sheets - first n characters

I have a google sheet with a column (A) of urls.
Xttps://tXco/008wnbebbw
Xttps://tXco/00lR1FNKBo
Xttps://tXco/00lR1Fw9cO
Xttps://tXco/00UwZwgh2h
Xttps://tXco/00UwZwxSqR
Xttps://tXco/00UwZwxSqR
Xttps://tXco/044TcIFl72
In column B I need to find all unique urls up to the 18th character. For instance column B should show:
Xttps://tXco/008wnbebbw
Xttps://tXco/00lR1FNKBo
Xttps://tXco/00UwZwgh2h
Xttps://tXco/044TcIFl72
I have this formula which I was trying to adapt for it (not sure if it helps at all). I was trying to adapt this to use with =UNIQUE( ?
=SUMPRODUCT(--(LEFT($A$1:$A$15,18)=LEFT(A1,18)))>1
If it helps to take a look at the sheet, here it is: https://docs.google.com/spreadsheets/d/1tG7TpHNvNY86PRiePsKyKfxnuEZah6T7ZDL7dXOIcEA/edit?usp=sharing
Thanks in advance!
You may try this formula:
=ArrayFormula(vlookup(
UNIQUE(FILTER(LEFT(A2:A,17),A2:A<>"")),
FILTER({LEFT(A2:A,17),A2:A},A2:A<>""),
2,0))
How it works
it will first find unique left N chars:
UNIQUE(FILTER(LEFT(A2:A,17),A2:A<>"")
then get left N chars and original strings:
FILTER({LEFT(A2:A,17),A2:A},A2:A<>"")
and then use vlookup to get top first entry for uniques.
Try this instead without the extra column. Put it in B1:
=unique(arrayformula(if(left(A1:A,18)=left(A1:A,18),A1:A,"")))
Try this: =unique(arrayformula(left(A1:A,18)))

Countif with len in Google Spreadsheet

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.

Resources