How to remove blank rows in Google sheets - google-sheets

I was wondering if there was a way to quickly remove blank rows using a formula like COUNTA?
I have something like this with blanks:
Chocolates
Bounty CHOC001
Twix CHOC002
Snickers CHOC003
Mars CHOC004
Kinder Bueno CHOC005
Dairymilk CHOC006
Wispa CHOC007
Now I want it to be like this with blanks removed:
Chocolates
Bounty CHOC001
Twix CHOC002
Snickers CHOC003
Mars CHOC004
Kinder Bueno CHOC005
Dairymilk CHOC006
Wispa CHOC007
Thanks

Assuming the list is in column A, you can try
=filter(A2:A10, len(A2:A10))
If you want to incorporate this in the formula I provided earlier, you can try
={"Chocolates"; query(ArrayFormula(regexreplace(proper(A2:A10), "(?i)ch(o|0)c", "CHOC")), "where Col1 <>''",0)}

Related

How to return all matching values without duplicates into one cell in Google Sheet?

I'm stuck trying to vlookup multiples values duplicates and return all match into one cell.
I would like to convert with formulas a sheet like this:
Name
Product
James
Peach
James
Apple
James
Cherry
Andy
Banana
Wallace
Peach
Wallace
Cherry
Mike
Banana
On a new sheet like this:
Name
Product
James
Peach,Apple,Cherry
Andy
Banana
Wallace
Peach,Cherry
Mike
Banana
Here is an example spreadsheet
Edit: I forgot to specify it, but the result should be in a new tab, like a vlookup
I have not found a functional solution in my research, here is the post that seems to come closest to my need. But the proposed formula does not work: =TEXTJOIN(",",TRUE,IF($A$2:$A$11=E2,$C$2:$C$11,""))
Do you have any idea how I can solve this formula? Your help will be greatly appreciated. I'm going in a loop and I can't find a solution :(
You can use:
=JOIN(", ";FILTER(B:B;A:A=E2;B:B<>""))
Or for the whole column:
=byrow(E2:E;lambda(each;if(each="";"";join(", ";filter(B:B;A:A=each;B:B<>"")))))
use:
=LAMBDA(x; {UNIQUE(FILTER(x; x<>""))\BYROW(UNIQUE(FILTER(x; x<>""));
LAMBDA(a; TEXTJOIN(", "; 1; FILTER(OFFSET(x;;1); x=a))))})
(Input!A2:INDEX(Input!A:A; MAX(ROW(Input!A:A)*(Input!A:A<>""))))

Explode each row into multiple rows by splitting a column of a given computed range

I was recently tasked with 'exploding' each row in a given range with respect to the split value of one of the columns, i.e. going from
Name
Interests
Age
John
swimming, movies
31
Mary
basketball
26
Richard
football, music
21
to:
Name
Interest
Age
John
swimming
31
John
movies
31
Mary
basketball
26
Richard
football
21
Richard
music
21
It's a little similar to a Cartesian product, only one of the terms needs to be computed on the basis of the value in the Interests column. I eventually solved it using an Apps Script function, but I'm wondering if it could be easily solved using a regular formula.
Note that the input range in my case was a product of another formula (a QUERY(...), to be exact), so not necessarily contiguous or addressable within the spreadsheet.
Any ideas?
try:
=INDEX(QUERY(SPLIT(FLATTEN(A1:A&"×"&SPLIT(B1:B, ", ", )&"×"&C1:C), "×"),
"where Col3 is not null"))
You can use the custom "UNPIVOT" function found on this sheet. File>Make a Copy to grab the script. Also here on github.
=ARRAYFORMULA(UNPIVOT(A2:A,"V",SPLIT(B2:B,", ",0),"B",C2:C,"V"))
You would then QUERY() the output to eliminate the rows where there was nothing in the second column.

How to import some Infinitely Repeating Offset-Cells from an ImportRanged WorkSheet? (Google Sheets)

I'm trying to import some specific cells from one worksheet to another, and I want to do so in a repeating, intermittent way.
For instance, if A51 is the first cell to be imported, I want to import A51 and all "reoccuring next fifth cells" in the same row (A56, then A61, then A66 and so on).
I figured I'd only need to use ArrayFormula, ImportRange and Offset, but I couldn't be more wrong. In my inexperienced mind, the formula would look something like this:
=ARRAYFORMULA(OFFSET(IMPORTRANGE("url";"Page1!A51:51");0;5))
... but it obviously doesn't work. I keep falling into the same problem no matter how much I tweek it, "the argument must be an interval". I've stumbled across similar problems here in StackOverflow, but none of them were quite the same issue; I tried their solutions and they also didn't work.
e.g. Exemple
So now I resort to you, great SO community. Could anyone explain to me why am I failing so miserably in a (most probably) simple task? I appreciate any help!
Thanks!
First see if you can just omit blank values and get the result you want. In the Input spreadsheet, choose Insert > New sheet and put this formula in cell E4 of the new sheet:
=query( transpose('Página1'!B4:4); "where Col1 is not null"; 0 )
You can then do the same in the Output spreadsheet with these formulas:
=query( transpose(importrange("1el8PStX7NxRLbL-LC1afPTY3zAv2QqaQotRR18o0EjM"; "Página1!B4:4")); "where Col1 is not null"; 0 )
=query( transpose(importrange("1el8PStX7NxRLbL-LC1afPTY3zAv2QqaQotRR18o0EjM"; "Página1!B6:6")); "where Col1 is not null"; 0 )
If that is not what you needed, please show more realistic-looking sample data in the Input spreadsheet and the hand-entered results you would like to get from that data in the Output sheet. Do not show ColB;Row4 but the actual results you would like to get.

=QUERY(ImportRange -- Can I bring Col14 and Col15 of original sheet into the new sheet at a diff cell?

Current function, working perfectly so far:
=QUERY(ImportRange("doclink", "Info!A2:S"), "Select Col1,Col3,Col4,Col5,Col6,Col7,Col8,Col9,Col12 WHERE Col18='At Risk' order by Col1 asc")
In my original sheet I have Col14 and Col15 with relevant info I'd like to transpose into my new sheet's Col13.
Is this even possible to input 2 cells' info into 1 new cell?
How would I pull from those and "skip" inputting in Col10, Col11, Col12 of the new sheet? (new info needs to go there that is not pulled from original sheet)
Feel free to point me in the right direction or even let me know if this is possible. I've been googling for a bit but I think my lack of vernacular is limiting what I find.
Many thanks!
So far it looks as if your column 15 would need 2 separate imports joined together like this which is a bit ugly I'm afraid:
=ArrayFormula({query(importrange("...","sheet6!a:s"),"Select Col14 where Col18='At Risk'")&
query(importrange("...","sheet6!a:s"),"Select Col15 where Col18='At Risk'")})

Google Spreadsheet SUMIF with criterion containing wildcards

Please see the data example in the image below...
I would like to sum the amounts separately by months and years.
How can I do this using SUMIF ?
My idea was very simple - to have formula for each month and for each year, like this:
=SUMIF(A1:A100,"2018-01-*",B1:B100)
=SUMIF(A1:A100,"2018-02-*",B1:B100)
=SUMIF(A1:A100,"2018-03-*",B1:B100)
..etc
=SUMIF(A1:A100,"2018-*",B1:B100)
=SUMIF(A1:A100,"2019-*",B1:B100)
..etc
But this formulas don't work. Something is wrong with the criterion.
So what am I doing wrong ? Am I using wildcards incorrectly ?
Example of data that I have
The problem here is that cells containing dates are special and cannot be compared to criterion like 2018-08-*.
The workaround is to use SUMIFS and then set each criterion with the DATE() function. Here is example for 2018-07:
=SUMIFS(B2:B100,A2:A100,">="&DATE(2018,7,1),A2:A100,"<"&DATE(2018,8,1))
You could use Query as in the image below (showing sum for 8th month - August):
By changing month(A)+1=8 you will have different months.
Code:
=QUERY(A1:B5;"select sum(B) where month(A)+1=8 label sum(B) ''";0)
Is that OK for you?

Resources