Forum Discussion
Nishkarsh31
Apr 09, 2021Brass Contributor
How to generate a sequence with 3 consecutives 1's and 3 consecutives 0's based on a table?
I've already got a formula, it's almost efficient Needs minor correction. I've attached a sample file. It's self explanatory. PeterBartholomew1 SergeiBaklan
- Apr 09, 2021
I would recommend sticking with integers for this type of calculation in order to avoid rounding error problems altogether. In particular, the integer divide function QUOTIENT can be valuable when you want to group values.
= LET( k, SEQUENCE(1,COLUMNS(Recipe),2), MOD(QUOTIENT(k,3),2) )
Normally 'k' should be a zero-based index but here you want a two cell offset with only one opening zero.
PeterBartholomew1
Apr 09, 2021Silver Contributor
I would recommend sticking with integers for this type of calculation in order to avoid rounding error problems altogether. In particular, the integer divide function QUOTIENT can be valuable when you want to group values.
= LET(
k, SEQUENCE(1,COLUMNS(Recipe),2),
MOD(QUOTIENT(k,3),2) )
Normally 'k' should be a zero-based index but here you want a two cell offset with only one opening zero.
- Nishkarsh31Apr 10, 2021Brass ContributorThank you sir.
I didn't understand the zero-based index thing.
Although I'm okay with the first cell not being a zero,
If it directly starts with consecutive 1s and 0s. That works as well- PeterBartholomew1Apr 10, 2021Silver ContributorIf you were to use Power Query, say, you would see an option to create an index column. Normally one would think of numbering the records starting at 1, {1;2;3;4;...} but, for some calculations, starting at 0 is better {0;1;2;3;...}.
To start with consecutive zeros, your sequence formula should start of 0 rather than 2.