This question already has answers here:
Repeat range of items multiple times in Google Sheets
(5 answers)
Repeat whole row N times based on column value in Google Sheets
(2 answers)
Repeat each row N times in Google Sheets
(4 answers)
Closed 5 months ago.
I've searched and cant find the answer to this seemingly easy task
I'm looking to repeat A1:A4 n times
A1:A4=
California
Off
Texas
Off
Desired output: n=4
California
Off
Texas
Off
California
Off
Texas
Off
California
Off
Texas
Off
California
Off
Texas
Off
There are multiple ways to repeat text in columns:
Solution 1:
=FLATTEN(TRANSPOSE(ARRAYFORMULA(SPLIT(REPT(A1:A4&";",B1),";"))))
Where B1 is the number of the repetition.
Solution 2:
You may also use Join
=transpose(split(rept(join(",",A1:A4)&",",4),","))
Solution 3:
You can also use TextJoin
=FLATTEN(split(REPT(TEXTJOIN("^",TRUE,(A2:A),"^"),B2),"\^"))
Result:
try:
=INDEX(FLATTEN(TEXT(TRANSPOSE(A1:A4); FLATTEN(SPLIT(REPT("#×"; 4); "×")))))
or see: https://stackoverflow.com/a/54266697/5632629
Related
This question already has answers here:
Repeat range dynamically
(2 answers)
Closed 15 days ago.
I have a column containing x rows of names and I want to be able to repeat those rows of names x times each in another row.
It should be possilbe to have at least 15 names and repeate it 900 times.
Here an example:
I tried this now for about 6 hour with arrayformula etc. and didn't find any working solution..
For example =TRANSPOSE(split(rept(join(";",A:A)&";",10),";")) would do the job, but the rept function is limited in characters, so it doesn't work for this case..
Are you able to do this?
You can try with REDUCE and SEQUENCE like this. It's wrapped in QUERY to exclude empty rows, so you can get your full column as input, despite its amount of elements:
=QUERY(REDUCE(,SEQUENCE(A1),LAMBDA(a,v,{a;B1:B})),"Where Col1 is not null")
use:
=INDEX(FLATTEN(TEXT(TRANSPOSE(A1:A4); FLATTEN(SPLIT(REPT("#×"; 5); "×")))))
This question already has answers here:
How to create all possible pair combinations without duplicates in Google Sheets?
(5 answers)
Google Sheets - generating all possible combinations of strings from columns
(2 answers)
Closed 2 months ago.
In Google Sheets, how can I generate a list of the combinations of a given length of numbers between 1 and n?
For example all combinations of length 2 from 1 to 4 would be:
1,2
1,3
1,4
2,3
2,4
3,4
This question already has answers here:
Repeat whole row N times based on column value in Google Sheets
(2 answers)
How to Repeat a Data Set (several columns) x times in Google Sheets [duplicate]
(1 answer)
Repeat range of items multiple times in Google Sheets
(5 answers)
Closed 5 months ago.
I need to create a weighted lottery where people can have multiple entries and the number of entries is based upon a series of questions. For each question they get right, they get an entry into the lottery.
In my head, I've got a table with the participants' names and their total number of points (entries), then I need some way to have a list of the names with their multiple entries. So if my initial table looked like this:
Name
Points
John
5
Larry
4
Andre
2
Mika
6
Then my output list would look like this:
Name
John
John
John
John
John
Larry
Larry
Larry
Larry
Andre
Andre
Mika
Mika
Mika
Mika
Mika
Mika
Then I could just use the default row leaders from the output table as the entry for the person and use a random number generator to pick numbers.
That being said, I'm open to other ideas.
Try this formula-
=QUERY(INDEX(FLATTEN(SPLIT(REPT(A1:A4&"#",B1:B4),"#"))),"where Col1 is not null")
REPT(A1:A4&"#",B1:B4) will repeat each cell value of A1:A4 as per number in B1:B4. Then Split and flatten with make them a vertical array (column). Query() will return all the values except nulls (if any).
To make it more dynamic you may try-
=QUERY(INDEX(FLATTEN(SPLIT(REPT(A1:INDEX(A1:A,COUNTA(A1:A))&"#",B1:INDEX(B1:B,COUNTA(A1:A))),"#"))),"where Col1 is not null")
And with new LAMBDA() functions.
=FLATTEN(SPLIT(JOIN("",BYROW(A1:INDEX(B1:B,COUNTA(A1:A)),LAMBDA(x,REPT(INDEX(x,1,1)&"|",INDEX(x,1,2))))),"|"))
This question already has answers here:
Repeat whole row N times based on column value in Google Sheets
(2 answers)
Closed 4 months ago.
I have a list of users and a value that denotes how many times I want to return the user's name.
How do I set up a formula that helps me output this?
try:
=INDEX(QUERY(FLATTEN(IFERROR(SPLIT(REPT(A2:A&"×"; B2:B); "×")));
"where Col1 is not null"; ))
This question already has an answer here:
Google Sheet SUMIF not summing range
(1 answer)
Closed 3 years ago.
I am making a sheet to oversee funds
I am trying to make something like this in Google Sheets
D(n) = D(n-1) + B(n) - C(n) for the entire row of D
and so on for the entire row
I also would prefer if the remaining fund didn't show up unless a value for received or spent has been input
You can use SUMIF to get running totals of columns B and C, and subtract one from the other:
=ArrayFormula(if((B3:B="")*(C3:C=""),"",sumif(row(A3:A),"<="&row(A3:A),B3:B)-sumif(row(A3:A),"<="&row(A3:A),C3:C)+D2))
try:
=ARRAYFORMULA(IF((B3:B)+(C3:C),
MMULT(TRANSPOSE((ROW(B3:B)<=TRANSPOSE(ROW(B3:B)))*B3:B), SIGN(B3:B))+D2-
MMULT(TRANSPOSE((ROW(C3:C)<=TRANSPOSE(ROW(C3:C)))*C3:C), SIGN(C3:C)), IFERROR(1/0)))