Count values in row where first column is value - google-sheets

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")

Related

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))

Google Sheets conditional formating based on % of another value

I have the following data:
What I want to do is based on the values in column B (Planned) change the color of the background of cells in column C (Done). Until Matt reaches 50% of his 100 hours I want the background to be green, when he reaches 75% yellow, and 100% red. Same for other people If Jasmine 50% of 40 -> green and so on.
Those numbers in the planned column will be typed in manually.
Is there a way to achieve that?
green:
=C5/B5%<=50
yellow:
=C5/B5%<=75
red:
=C5/B5%=100
This needs 3 conditional format rules in the following order (the order is important):
Apply all rules to the range C5:C
Custom formula is =C5/B5 <= 0.5, set background colour green
Custom formula is =C5/B5 <= 0.75, set background colour yellow
Custom formula is =C5/B5 <= 1, set background colour red

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.

Merge values of an array into a single cell

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.

Resources