How to generate a repeating sequence of numbers in google sheet? - google-sheets

So what i need is quite simple, yet somehow i cant get around to find a solution for it.
Basically what i need is for a column, starting from its 2nd row to look list numbers from 1 to 15 and have that sequence repeated all the way to the bottom of the sheet automatically. i was thinking about using arrayformula but couldnt figure out the formula for it.
essentially something like this but it goes all the way down automatically.

Explanation:
You can repeat (REPT) a sequence of numbers from 1 to 15 by using the Sequence formula.
The maximum number of times you want to repeat this sequence will be determined by the total number of rows in your sheet divided by 15.
Solution:
=transpose(split(REPT(concat(JOIN(",",SEQUENCE(1,15)),","),ROUNDDOWN(ROWS(A1:A)/15)),",",true))
Output:

non-REPT solution:
=INDEX(ARRAY_CONSTRAIN(FLATTEN(
SEQUENCE(ROUNDUP(ROWS(A:A)/15), 15)-(
SEQUENCE(ROUNDUP(ROWS(A:A)/15), 1, 0)*15)), ROWS(A:A)-ROW()+1, 1))

Related

Google Sheets: Is there a way to make an Array for a sequence that grows to a repeat given number of times

I have managed to make this formula:
=IF(COUNTIF($A$1:A1,A1)=$B$1,A1+1,A1)
Is making an incremental list in the same column, starting with 01, and on cell B1 I am instructing how many times this number should repeat (up to 5 times per number). So, if I say repeat 2 times it looks like this:
Column A
1
1
2
2
How can I make it an Array Formula? I'm barely starting on Arrays so I'm just trying to learn as I go.
you can try to solve this with the following formula =ArrayFormula(flatten(if(SEQUENCE(1,C1),SEQUENCE(C2)))) but you should specify the value limit in cell C2 to which the numbers must increase, otherwise the formula will loop
Try this
=ARRAY_CONSTRAIN(arrayformula(query(flatten(split(rept("|"&A2:A,B2:B),"|")),"select * where Col1 is not null")),SUM(B2:B),1)
https://docs.google.com/spreadsheets/d/1qXy-hzWUnsUmAa-8aV5IHOyZABGD_h8ajICLwdyNge8/edit?usp=sharing
Try Sequence() with ROUNDUP() function.
=ArrayFormula(ROUNDUP(SEQUENCE(B1*B1)/B1,0))
When enter 3:

A formula to add one hour to the cell above in Google Sheets

Often I want to quick fill of a list of time similar to how I put a 1 in A1 and then in A2 I place A1 + 1 to get two and then I copy that down the next 100 cells to get from 1 to 100. I want to do the same thing with time. It also gives me the advantage of change the first cell and updating all the times. I asked this partly because the other answers are more complex and never get to a simple solution for this kind of process that is so often used.
to populate rows with numbers from 1 to 100 use:
=SEQUENCE(100)
to get time intervals use:
=INDEX(TEXT(SEQUENCE(12, 1, 0, 2)*"1:00:00", "hh:mm:ss"))
=INDEX(TEXT(SEQUENCE(
12 +N("number of rows"),
1 +N("number of columns"),
0 +N("start from midnight"),
2 +N("interval of increase"))
*"1:00:00" +N("period of increase"),
"hh:mm:s" &N("time format")))
Working through https://spreadsheetpoint.com/add-time-in-google-sheets/ I came up with:
Make sure the cells you are working with are in the time format you desire.
Place the time you want to start with in the first cell, let's say A1
To add an hour to the time in A1, use =A1+60/(24*60), let's say in A2
Now you can copy A2 down as far in column A you desire to get the time.
Notice, the 60 in the formula =A1+60/(24*60) is the number of minutes. Hence, if you want to do a half-hour, you can use 30.

Automatically Number/ Count All Columns or Rows in Google Sheets

I just wanted a simple way to number columns or rows in a Google Sheet, and most answers I've found offer many options that are far more complicated than I needed them to be.
Example: I want to number every column in the active sheet, starting with 1 for Column A and counting up by 1, regardless of the content of any other cells on the sheet and if I add columns to the sheet later, I want them to automatically update with the correct column numbers.
Another way is to use SEQUENCE.
So putting =SEQUENCE(99) in A1 would number the first 99 rows, from 1 to 99.
To number columns, just rotate that array, with TRANSPOSE.
So if A1 held =TRANSPOSE(SEQUENCE(26))
that would number columns A to Z with the numbers 1 to 26.
If you want to number both columns and rows,try:
in A1: =SEQUENCE(999), and
in B1: =TRANSPOSE(SEQUENCE(25,1,2))
I realise that this is numbering a specific number of rows, or columns, but I often find that very useful. You could modify this to number all columns or rows by adding some count to determine the total number of rows or columns, and using that in place of the first parameter for the SEQUENCE function.
The simplest way I've found to do this is by putting either of the following formulas in A1:
For numbering rows: =ArrayFormula(ROW(A:A))
And for columns: =ArrayFormula(COLUMN(1:1))
After putting the formula in A1, I'll usually hide the column or row the formula is in so I don't accidentally change or delete it.
If I want the counting to start at 1 on the 2nd, 3rd, or 4th row or column, then adding a -1,-2, or -3 respectively to the end of the formula gets that done.
For example: To number columns starting with 1 in Column C, the formula I put in A1 is =ArrayFormula(COLUMN(1:1)-2).
This may be way more basic than most people on this site are generally looking for, but for some reason it took me an unexpectedly long time to find it/ figure it out, so I thought maybe someone else would find it useful in the future.

Google Sheet - Transform two columns into one column using arrayformula (more than 50,000 characters)

I'm using Google Sheets and looking for an arrayformula that able to take a list in two columns and arrange it alternately in one column. The sheet contains about 5,000 rows, each row has more than 35 characters.
I tried this:
=transpose(split(join(" ", query(transpose(B5:C),,50000)), " "))
But then I got this message:
Please take a look at the sheet here:
https://docs.google.com/spreadsheets/d/11T1Roj1trviOSiiTZS292-4l3oODid7KLi9oGz3Z66o/edit#gid=0
Assuming your 2 columns are A and B, this formula will "interlace" them:
=query(
sort(
{arrayformula({row(A1:A3)*2, A1:A3});
arrayformula({row(B1:B3)*2+1, B1:B3})}
),
"select Col2")
Explanation, unwrapping the formula from the inside:
Each value gets a unique number, based on its row number times 2 (+1 for the 2nd column)
Everything is sorted based on this number
Only the 2nd column is extracted for the result.
There is a function for this called FLATTEN().
This works perfectly as a general solution since it takes an array of any size and outputs the items in the order they appear left-right-top-down (See here).
It can be combined with TRANSPOSE() to accomplish the same thing but in the horizontal case, and if needed blank cells can be omitted with FILTER().
EDIT:
My sincere apologies, I did not read the question carefully enough. My response is incorrect.
This should work:
={B5:B12;C5:C12}
just be careful to NOT change it to
={B5:B;C5:C}
This will start an infinite loop where the spreadsheet will increase the amount of rows in the spreadsheet to allow this output column to expand, but in doing so increases the length of the 2 input columns, meaning the length of the output column increases even more, so the spreadsheet tries adding more rows, etc, etc. It'll make your sheet crash your browser or something each time you try to open it.
In Row5:
=ArrayFormula(offset(B$5,INT((row()-5)/2),iseven(row())))
Would need to be copied down however.

Google Sheets ARRAYFORUMLA that can show 0 if the value is less than or equal to zero. Otherwise show the value of that set of data

I have set of columns that I am attempting to calculate the combined total of those columns then subtract from that total 8, if the difference after 8 is equal to or less than 0 I want to only show zero in the column I am doing this formula in. For those who might ask, I am using the ARRAYFORUMLA cause I want this calculation to repeat as I add new rows, keeping the totals I am seeking on the same row as the calculation is being done onto. So far I have most of this working. Well up to the IF ELSE THEN type of portion. My attempt is/was
=if(LTE((B3:B)+(C3:C)-8,0),ARRAYFORMULA((B3:B)+(C3:C)), 0)
As long as I'm understanding you correctly, I believe this will work:
=if(lte(sum(B2:C)-8,0),0,sum(B2:C))
It's at the top of the row and sums columns B and C. You can add more columns easily this way by either changing B/C to something else or passing more columns in.
Sum-8 is greater than 0
Sum-8 is less than 0
If what you want to do is to add each row to the total but only if its sum is 8 or greater, then your original formula was nearly OK but the two parts of the IF statement should have been reversed
=sum(ArrayFormula(if(LTE((B3:B)+(C3:C)-8,0),0,(B3:B)+(C3:C))))
You could also take most of the brackets out
=sum(ArrayFormula(if(LTE(B3:B+C3:C-8,0),0,B3:B+C3:C)))
and this would also work
=sum(ArrayFormula(if(LTE(B3:B+C3:C,8),0,B3:B+C3:C)))
Short answer
ARRAYFORMULA that can show 0 if the value is less than or equal to zero. Otherwise show the value of that set of data:
=ArrayFormula(IF(LTE(A1:A3,0),0,A1:A3))
Explanation
The basic IF syntax requires the use of scalar values, to use it with arrays, ARRAYFORMULA is required as an outer function:
ARRAYFORMULA(IF(array_logical_expression,array_if_true,array_if_false))
For the specific case described on the body of the question, the corresponding formula is:
=ARRAYFORMULA(IF(LTE(B3:B+C3:C-8,0),0,B3:B+C3:C))
Reference
Google Docs editors Help
IF
ARRAYFORMULA
Using arrays in Google Sheets

Resources