Home > OS >  Google Sheets: Create 1D array of a combination of values repeated a different amount of times
Google Sheets: Create 1D array of a combination of values repeated a different amount of times

Time:07-01

I am trying to create an array in google sheets based on a combination of two text values. Or perhaps a better explanation is I need to provide a position X for value B in a 5 cell array of values A and output the resultant combination of 5 cells based on the position chosen. See example below:

Value 1 Value 2 Position
A B X

Different Combinations:

Pos0 Pos1 Pos2 Pos3 Pos4
B A A A A
A B A A A
A A B A A
A A A B A
A A A A B

This formula will ultimately be nested inside an if statement...Please help!

CodePudding user response:

Assuming that value 1 is in cell A2, value 2 in B2 and the zero-indexed position in C2, use this formula in a free row:

=arrayformula( if( sequence(1, 5, 0) = C2, B2, A2 ) )

  • Related