SOLVED

How to generate a sequence with 3 consecutives 1's and 3 consecutives 0's based on a table?

%3CLINGO-SUB%20id%3D%22lingo-sub-2263321%22%20slang%3D%22en-US%22%3EHow%20to%20generate%20a%20sequence%20with%203%20consecutives%201's%20and%203%20consecutives%200's%20based%20on%20a%20table%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2263321%22%20slang%3D%22en-US%22%3E%3CP%3EI've%20already%20got%20a%20formula%2C%20it's%20almost%20efficient%3CBR%20%2F%3ENeeds%20minor%20correction.%3CBR%20%2F%3EI've%20attached%20a%20sample%20file.%20It's%20self%20explanatory.%3CBR%20%2F%3E%3CBR%20%2F%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F214174%22%20target%3D%22_blank%22%3E%40Peter%20Bartholomew%3C%2FA%3E%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F521%22%20target%3D%22_blank%22%3E%40Sergei%20Baklan%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-2263321%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EDeveloper%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EExcel%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EExcel%20for%20web%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EExcel%20on%20Mac%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EExcel%20on%20mobile%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EFormulas%20and%20Functions%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EMacros%20and%20VBA%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EOffice%20365%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EUser%20Adoption%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2263478%22%20slang%3D%22en-US%22%3ERe%3A%20How%20to%20generate%20a%20sequence%20with%203%20consecutives%201's%20and%203%20consecutives%200's%20based%20on%20a%20table%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2263478%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F523656%22%20target%3D%22_blank%22%3E%40Nishkarsh31%3C%2FA%3E%26nbsp%3BSuspected%20it%20to%20a%20rounding%20issue.%20Your%20formula%20included%20a%20factor%200.33.%20Changed%20it%20to%20%E2%85%93.%20Then%20it%20seems%20to%20work.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2264206%22%20slang%3D%22en-US%22%3ERe%3A%20How%20to%20generate%20a%20sequence%20with%203%20consecutives%201's%20and%203%20consecutives%200's%20based%20on%20a%20table%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2264206%22%20slang%3D%22en-US%22%3EIt%20did%20solve%20it.%20However%201%2F3%20is%20also%20calculated%20as%200.333333333333333%3CBR%20%2F%3EWon't%20it%20also%20create%20problem%2C%20after%20a%20particular%20no.%20of%20columns%3F%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2264212%22%20slang%3D%22en-US%22%3ERe%3A%20How%20to%20generate%20a%20sequence%20with%203%20consecutives%201's%20and%203%20consecutives%200's%20based%20on%20a%20table%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2264212%22%20slang%3D%22en-US%22%3EI%20just%20checked%20it%20does%20create%20the%20same%20problem%20at%20column%20EL%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2264315%22%20slang%3D%22en-US%22%3ERe%3A%20How%20to%20generate%20a%20sequence%20with%203%20consecutives%201's%20and%203%20consecutives%200's%20based%20on%20a%20table%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2264315%22%20slang%3D%22en-US%22%3EPerhaps%3A%3CBR%20%2F%3E%3DIFERROR(MID(REPT(%22111000%22%2CROUNDUP(COLUMNS(Recipe)%2F6%2C0))%2CCOLUMNS(%24B3%3AB3)-1%2C1)%2C0)%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2264390%22%20slang%3D%22en-US%22%3ERe%3A%20How%20to%20generate%20a%20sequence%20with%203%20consecutives%201's%20and%203%20consecutives%200's%20based%20on%20a%20table%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2264390%22%20slang%3D%22en-US%22%3EThis%20is%20not%20a%20dynamic%20formula.%3CBR%20%2F%3EI%20need%20one%20to%20spill%20result%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2264404%22%20slang%3D%22en-US%22%3ERe%3A%20How%20to%20generate%20a%20sequence%20with%203%20consecutives%201's%20and%203%20consecutives%200's%20based%20on%20a%20table%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2264404%22%20slang%3D%22en-US%22%3EI'm%20working%20off%20XL2016%20and%20don't%20have%20dynamic%20array%20excel.%20Try%20changing%20this%20part%3CBR%20%2F%3ECOLUMNS(%24B3%3AB3)%3CBR%20%2F%3E%3CBR%20%2F%3Eusing%20the%20sequence%20function%20to%20generate%20a%20sequence%20of%3A%201%20-%20Columns(Recipe)%3CBR%20%2F%3E%3C%2FLINGO-BODY%3E
9 Replies

@Nishkarsh31 Suspected it to a rounding issue. Your formula included a factor 0.33. Changed it to ⅓. Then it seems to work.

It did solve it. However 1/3 is also calculated as 0.333333333333333
Won't it also create problem, after a particular no. of columns?
I just checked it does create the same problem at column EL
Perhaps:
=IFERROR(MID(REPT("111000",ROUNDUP(COLUMNS(Recipe)/6,0)),COLUMNS($B3:B3)-1,1),0)
This is not a dynamic formula.
I need one to spill result
I'm working off XL2016 and don't have dynamic array excel. Try changing this part
COLUMNS($B3:B3)

using the sequence function to generate a sequence of: 1 - Columns(Recipe)
best response confirmed by Nishkarsh31 (Contributor)
Solution

@Nishkarsh31 

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.

Thank 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
If 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.