Spreadsheets get unique names but ignore blank cells - google-sheets

I would like to use spreadsheets to get all unique names from Column A in a table but in the same time I would like blank cells to be ignored. So far I've got this formula that returns all of the unique names from column A but I don't know how to go about ignoring blank cells and not repeating values that have once been added previously.
Here is how my document looks so far. As you can see everything stops after Megan because there is a blank cell.
=IFERROR(INDEX($A$2:$A$90, MATCH(0, COUNTIF($I$10:I10, $A$2:$A$90), 0)), "")
Searched long and wide but came up with nothing, if anyone has any idea how one could do that I would really appreciate it. Thanks!

=unique(A2:A) should work
=unique(filter(A2:A,A2:A<>"")) to also ignore blanks

Yet another hack
=SORT(UNIQUE(A2:A))
Technically, this does not remove the blank result. But nonetheless puts it at the end of the list. You'll also benefit from the sort if you need it. 😁

You can use query:
=unique(query(A2:A,"select A where A<>''"))

You can use this code:
=IFERROR(INDEX($A$2:$A$90, MATCH(0, INDEX(COUNTIF($I$10:I10, $A$2:$A$90)+($A$2:$A$90=""), ), 0)), "")
should work

Related

Processing a list to output in a particular format

I am processing a list to output its items in chunks separated by blank rows as follows. But the result is not working when there are similar items, as shown with the arrows.
The formula I'm using is =query(filter(flatten({if(COUNTIFS($A$1:$A,$A$1:$A,ROW($A$1:$A),"<="&ROW($A$1:$A))=1," ",),A1:A}),flatten({if(COUNTIFS($A$1:$A,$A$1:$A,ROW($A$1:$A),"<="&ROW($A$1:$A))=1," ",),A1:A})<>""),"offset 1",0)
I need some help with it, to get the repeated chunks right too, so that the desired result is following. I've tried tweaking the COUNTIF conditions but am struggling.
Desired result
try:
=INDEX(LAMBDA(a, QUERY(FLATTEN(SPLIT(QUERY(IFERROR(
IF(a={""; a},"×"&a,"×​×"&a)),,9^9), "×")), "offset 1", ))
(A1:INDEX(A:A, MAX(ROW(A:A)*(A:A<>"")))))
When I opened it, there was no answer but here it goes all the same for you or another user 😉
It checks each row with the next one and adds a "|" when they differ, then joins all rows with that same symbol and split by that same symbol, resulting in empty rows between different values
=transpose (split(join("|",byrow(A1:A,lambda(each,if(each="","",SI(each=offset(each,1,0),each,each&"|"))))),"|",1,0))
Here's another solution:
=index(lambda(a,b,query(flatten(split(
a&if(a=b,,"❆ "),"❆")),"where Col1<>''"))
(filter(A:A,A:A<>""),{filter(A2:A,A2:A<>"");0}))

XPath text() returns an extra blank value

I'm scraping this site, specifically the content of the tables inside the div tags with class containing 'ranking-data'. So for the first td that would be:
//div[contains(#class, 'ranking-data')]//tr[th//text()[contains(., 'TIN')]]/td[1]/text()"
This is working fine for all columns in all tables (with needed modifications) except for a cell in column 2 that contains an i tag: on Google Spreadsheets it adds an extra blank cell below the cell with the text itself. I've first tried to scrap it with:
//div[contains(#class, 'ranking-data')]//tr[th//text()[contains(., 'TIN')]]/td[2]/text()
Then I've tried something like *[not(i[contains(#class,'info-circle')])]/text() after the td[2], and some other variants, but it doesn't work.
How can I avoid this i tag?
try:
=QUERY(IMPORTXML(A1, "//div[contains(#class, 'ranking-data')]//tr[th//text()[contains(., 'TIN')]]/td[2]/text()"), "where Col1 <>' '", )
Answer given by #player0 is working for my case, and since it was the first answer I won't remove the "accepted" mark from it; but I'm stubborn and I've find an alternative with just XPath (which may be useful for other cases). It was as simple as adding an [1] at the end of my first query:
//div[contains(#class, 'ranking-data')]//tr[th//text()[contains(., 'TIN')]]/td[2]/text()[1]

Formular for counting names in a spreadsheet which are seperated with , or /

so I want to count the names in a cell which are separated with , or / like that
I tried several thing but nothing seems to work and I always get an error, can you help me out?
I tried the following formulas:
=ArrayFormula(if(len(B457:B),len(B457:B)-len(SUBSTITUTE(B457:B,",",""))+1,))
OR even easier like:
This
=LEN(TRIM(A1))-LEN(SUBSTITUTE(TRIM(A1),",",""))+1
It would be enough if it would just count all names separated with , ...so we'd just tell people to ad a , to separate their names and not a /..but it would be nice if both would work!
Thanks so much in advance!
Best regards
Paul
use semicolon:
=ARRAYFORMULA(IF(LEN(B457:B); LEN(B457:B)-LEN(SUBSTITUTE(B457:B; ","; ""))+1; ))
Try this in cell C457 (removing all content below):
=arrayformula(if(B457:B<>"",len(regexreplace(regexreplace(B457:B,"[\/\,]$",),"[^\/\,]+",))+1,))
My example sheet screengrab works from row 2:

How to use arrayformula in googlesheet to count the column with condition?

Hi everyone,
I'm trying to count the number of "Yes" appeared in each row. I want to use array formula so that I'm not required to have formula in each cell in column G. May I know arrayformula can achieve this or there is other method? I tried to use arrayformula(countif(B4:F4,"Yes")) but nothing come out for row 5,6,7,8. Hope to get some advice on this problem as I'm new to google sheet. Thank you.
Give this a try.
=ARRAYFORMULA(COUNTIF(IF(B4:F="Yes", ROW(B4:B8)), ROW(B4:B8)))
Edit: For the case that you describe below (only including certain columns), it's a little more involved, but the same principle works.
=ARRAYFORMULA(COUNTIF(IF(B4:B="Yes", ROW(B4:B8)), ROW(B4:B8)) + COUNTIF(IF(D4:D="Yes", ROW(D4:D8)), ROW(D4:D8)) + COUNTIF(IF(F4:F="Yes", ROW(F4:F8)), ROW(F4:F8)))

Why is this IMPORTRANGE formula not working?

I keep getting an error while using the IMPORTRANGE formula:
=importrange(“1uUbz2HAzgwBwY3zMXqcLJM_Z8qVQZHNP0wzRaNHceTc”, “Sheet1!A:B”)
I changed the name of my sheets several times to make sure everything matches but see a:
Formula parse error
and I am not sure what I am doing wrong. The original sheet has several tabs as well.
Can you see where the error is?
This worked for me:
=importrange(“1uUbz2HAzgwBwY3zMXqcLJM_Z8qVQZHNP0wzRaNHceTc”; “Sheet1!A:B”)
Maybe try it with a semicolon
Add the link format
eg
=importrange("https://docs.google.com/spreadsheets/d/1uUbz2HAzgwBwY3zMXqcLJM_Z8qVQZHNP0wzRaNHceTc","Sheet1!A:B") this should fix it
One other issue that can prevent import range from working is leading or trailing space in your sheet name. Make you check the sheet tab and clean out any leading or trailing spaces or your formula won't work. :-)
I burned an hour reading this thread and recreating my formula over and over again before I finally found the issue.
You have it as Sheet1!A:B, but you are missing the single quotes to identify the sheet name.
It should be 'Sheet1'!A:B instead.
The full formula is below:
=importrange(“1uUbz2HAzgwBwY3zMXqcLJM_Z8qVQZHNP0wzRaNHceTc”, “'Sheet1'!A:B”)
Make sure the sheet you're trying to import from is saved as a google sheet. I was trying to import an .xls file into a google sheet, and it wouldn't work. I re-saved the sheet as a google sheet and it fixed the problem immediately.
Problem
This formula does not work
=importrange(“1uUbz2HAzgwBwY3zMXqLJM_Z8qVQZHNP0aNHceTc”,“Sheet1!A:B”)
Reason why
You use curly double quotes “ ” instead of straight double quotes " "
SOLUTION
Change the quotes from curly to straight
=importrange("1uUbz2HAzgwBwY3zMXqLJM_Z8qVQZHNP0aNHceTc","Sheet1!A:B")
Be careful
If you have different locale you must also change , to ;

Resources