Merge values of an array into a single cell - google-sheets

I have an array that I would like to put into a single cell, with commas to make a list. I'm starting with an array of varying length in column BY:
Red
Blue
Green
Yellow
Purple
Brown
White
Black
Orange
and I want to have all of these put into a cell so it reads, "Red, Blue, Green, Yellow, Purple, Brown, White, Black, Orange"
The list is dynamic, so sometimes it will be just 1 color and other times it may have 50 colors.
I was trying things like,
=concatenate(arrayformula('1'!BY1:BY))
but that returns RedBlueGreenYellowPurpleBrownWhiteBlackOrange
Any ideas for me? Thank you in advance!
NJD

The function you want is join, as in
=join(", ", BY1:BY)
or, since you probably want to exclude empty cells at the bottom of that column,
=join(", ", filter(BY1:BY, len(BY1:BY)))
where filter keeps only nonempty cells.

Related

Count values in row where first column is value

I would like to create a formula that counts the times the column contains "blue" when the name is "Anna"
In this example that would be a total of 3.
Anna
Krijn
Fieke
Anna
Krijn
Fieke
blue
green
blue
green
blue
green
green
blue
green
blue
green
blue
blue
green
blue
green
blue
green
I've tried COUNTIFS, but couldn't get it to work because the name appears multiple times in the first row.
the setup in the screenshot should be helpful in what the formula is aiming at:
=COUNTIF(IFERROR(FILTER({A2:F},A1:F1=H2)),I2)
or to place it more directly:
=COUNTIF(IFERROR(FILTER({A2:F},A1:F1="Anna")),"blue")
use:
=SUMPRODUCT(FILTER(A31:F; A30:F30="Anna")="blue")

Combining INDEX(MATCH()) with ARRAYFORMULA() fails

I need a formula for the VariantAttribute column, which fills in the ProductAttribute value based on the first 4 characters of the VariantID
Desired result:
ProductID
ProductAttribute
VariantID
VariantAttribute
ABCD
blue
ABCD-xx
blue
BCDE
black
ABCD-yy
blue
CDEF
orange
BCDE-vv
black
DEFG
blue
BCDE-ww
black
CDEF-uu
orange
DEFG-zz
blue
ABCD-uu
blue
I tried to combine ARRAYFORMULA() with INDEX(MATCH())but failed, obviously because I'm not able to specify a search range within ARRAYFORMULA()
How can I get the desired result?
Assuming the dash ("-") is consistent.
=ARRAYFORMULA(IF(D2:D="",,VLOOKUP(INDEX(SPLIT(D2:D,"-"),,1),A:B,2,0))

Make cell color match neighboring cell only if text is present

I am working in a Google Doc spreadsheet and trying to make the background colors of cells in Column C match those of the neighboring cells in Column B as soon as any text is entered.
Column B is a pull down with 5 choices. Two choices have pink backgrounds and the others are white.
I want blank cells in Column C to stay white (even if B is pink) until text is entered, then match the color in B and update if B is updated. Is that possible?
Thanks

Conditional formatting of rows alternating at 4 rows at a time?

For example, row 1-4 would have red background, row 5-9 would be blue, then 10-13 would be back to red, etc
all the tutorial I found only covers alternating each row.
you can use MOD of 8 rows 4 times while each time you offset it by one row like:
=NOT(MOD(ROW(A1:A), 8))
I suggest
=mod(row()-1,8)>3
with a default fill colour of red.

Using conditional formatting to shade alternating groups of cells of variable size

I am facing an issue where I need to shade a row of cells either blue or orange based on if the user has check-marked the "swap" cell.
Essentially, the rows will start blue and continue to be blue.
When the user presses the checkmark in the Swap column, all rows after that point will now be orange.
Once again, if the user presses the checkmark in the Swap column (below the above checkmarks), the rows will go back to being blue from that point on.
This will alternate forever, as demonstrated in this image.
I am using some conditional formatting code that uses a "helper" column that is hidden. If the value is 1, then the row is coloured orange. If the value is 0, it is coloured blue. The problem is I don't know how to "search" for groups of checkmarks. Each checkmark will only colour the individual row it is in.
The helper column has this code: =MOD(IF(ROW()=2,0,IF(D25=D24,E24, E24+1)), 2)
The D column is where the checkmarks are, and begins at D24.
The E column is my helper column and begins at E24.
I can scrap this whole setup if someone can guide me into how to set this up.
I need it to essentially "change" the values of every row below a checkmark, until it finds another checkmark, and do the reverse so that the colouring can properly format.
Assuming 0:00 is in A1, please select ColumnsA:C and: (i) fill all with 'standard' fill blue and (ii) Format > Conditional formatting..., Format cells if... Custom formula is and:
=isodd(COUNTIF($C$1:$C1,TRUE))
with brown highlighting.

Resources