Equally divide a list of names in Google Sheets - google-sheets

We are using Google Sheets to track a list of about 60 people. We add and remove some each week. I am using functions like this to join them into a groups, =TEXTJOIN(", ", TRUE,$A$2:$A$15)
I would like to replace the $A$2:$A$15 part with something that would take 1/5th of the total list regardless of how long or short it becomes. Is this possible?

If you want to group only the first fifth:
=TEXTJOIN(", ", TRUE,$A$2:INDEX($A$2:$A,ROUNDUP(COUNTA(A2:A)/5)))
or if you want group all:
=TEXTJOIN(", ", TRUE,FILTER($A:$A,ROW($A:$A)>=(ROUNDUP(COUNTA($A:$A)/5)*(ROW()-2)+2),ROW($A:$A)<=(ROUNDUP(COUNTA($A:$A)/5)*(ROW()-1)+1)))

try:
=TEXTJOIN(", ", 1, INDIRECT("A2:A"&ROW(A2)-1+ROUNDDOWN(COUNTA(A2:A)/5)))

or:
=TEXTJOIN(", ", 1,
QUERY(A2:A, "where A is not null limit "&ROUNDDOWN(COUNTA(
QUERY(A2:A, "where A is not null", 0))/5), 0))

Related

How to sum results obtained with VLOOKUP and IMPORTRANGE in Google Sheets?

I'm currently obtaining the result with the formula below, which was nicely provided by player0, but the challenge now is to obtain not only the figure found, but a sum, since the occurrences in the "database" may be multiple.
=Arrayformula(if(A9:A="";;IFNA(vlookup(A9:A&D9:D&"Expedição"&"Costura";
{IMPORTRANGE("fileId";"Produção!F2:F")&
IMPORTRANGE("fileId-1n3nQ";"Produção!H2:H")&
IMPORTRANGE("fileId-1n3nQ";"Produção!R2:R")&
IMPORTRANGE("fileId-1n3nQ";"Produção!B2:B")\
IMPORTRANGE("fileId-1n3nQ";"Produção!N2:N")};2;0))))
I have tried including sum in many places in the formula above, but with no success.
Here's a file with dummy data.
Thanks in advance.
use:
=ARRAYFORMULA(IF(A4:A="",,IFNA(VLOOKUP(A4:A&" "&C4:C&" Expedição Costura ",
QUERY(SPLIT(FLATTEN(QUERY(TRANSPOSE(QUERY({IMPORTRANGE(
"1gh5w0czg2JuoA3i5wPu8_eOpC4Q4TXIRhmUrg53nKMU", "Data Origin!A2:R")},
"select Col6,Col8,Col18,Col2,'×',Col14 where Col14>0 label '×'''", )),,9^9)), "×"),
"select Col1,sum(Col2) where Col2>0 group by Col1"), 2, 0))))

going from wide to long with empty cells in google sheets

I am trying to go from wide to long for two columns with blanks retaining information in the last two columns.
Please see google sheets link for example and intended effect:
use:
=INDEX(QUERY(SPLIT(FLATTEN(
IF(A2:B5="",,A2:B5&"×"&C2:C5&"×"&D2:D5)), "×"),
"where Col2 is not null", ))
This may work:
=IF(ERROR(ARRAYFORMULA(split(FLATTEN(A2:B4&"!"&C2:C4&"!"&D2:D4),"!"))) = "FALSE" ,ARRAYFORMULA(split(FLATTEN(A2:B4&"!"&C2:C4&"!"&D2:D4), "!")))," ")

Google Spreadsheet ArrayFormula + VLookup Transformation

I have the following table on Google Spreadsheet:
And would need to get the following transformation result:
I precise that for each vegetable i can have only 1 buy price, and 1 or several sell prices
I am pretty sure this can be achieved combining ArrayFormula() + Vlookup() but have not been able to find the right formula so far. Any help would be welcomed
Thanks in advance
Cheers
Yoann
try:
=INDEX(SPLIT(FLATTEN(QUERY(TRANSPOSE(QUERY(QUERY(
{A2:C, IF(B2:B="buy", CHAR(13)&C2:C, C2:C)},
"select Col1,max(Col3) where Col1 is not null group by Col1 pivot Col4"),
"offset 1", 0)),,9^9)), " "))

sum google sheet and break line in different date

I want to sum in a column but this sum need to break if is a different day
here a small example google sheets
Found this but formula '=SUMIF(ARRAYFORMULA(MONTH(Sheet1!A2:A)),1,Sheet1!B2:B)'
Do You mean something like this ?
={"Total"; ArrayFormula(if(len(A2:A),if(match(A2:A, A2:A, 0)=row(A2:A)-1,sumif(A2:A,A2:A,B2:B),),))}
JPV, I'm wondering if your solution would only work if there were exactly two entries per date.
My suggestion (in C2):
=ArrayFormula(IF(INDIRECT("A2:A"&ROWS(A:A)-1)="","",IF(A3:A=INDIRECT("A2:A"&ROWS(A:A)-1),"",VLOOKUP(INDIRECT("A2:A"&ROWS(A:A)-1),QUERY(A2:B,"Select A, SUM(B) Where A Is Not Null Group By A Order By A Desc"),2,FALSE))))
try:
=ARRAYFORMULA(IF(COUNTIFS(A2:A, A2:A, ROW(A2:A), "<="&ROW(A2:A))=1,
IFNA(VLOOKUP(A2:A, QUERY(A2:B,
"select A,sum(B) where B is not null group by A"), 2, 0)), ))

Delimiting a column using "OR" in Google Sheets

I am using google sheets and would like to combine the text in cells of a column to a single cell separated by "OR" (with spaces on either side of the OR"
For example
**Column A**
John
Bob
Jim
Donald
would be combined in a single cell as "John OR Bob OR Jim OR Donald"
What formula in Google Sheets would I use to accomplish this?
try:
=JOIN(" OR ", A1:A4)
or:
=TEXTJOIN(" OR ", 1, A:A)
if you hit the limit try:
=ARRAYFORMULA(A1&" "&QUERY(IF(A2:A<>"", "OR "&A2:A, ),,999^99))
See if this works
=textjoin(" OR ", 1, A2:A)
Change range to suit.

Resources