Count of values based on preceding rows - excel

Some hundreds of rows of column A is filled in random order with color names (white, blue, green, yellow, red).
I need a formula in column B to show how many rows are BEFORE that row that contains the same color (standing in column A).
Example:
A B
white 0
yellow 0
yellow 1
green 0
white 1
yellow 2

Formula:
=COUNTIF($A$1:$A1,$A1)
Place the formula in cell B1 and fill down.

you need to move your data in column A one row down and then put this formula in B2, like this:
=COUNTIF($A$1:$A1,$A2)
And then copy and fill down the formula.

Related

Sum a column based on matching a cell reference in another?

The yellow cells both have the formula =A2. I want a formula I can put into the red cells, which sums the blue cells if the cell reference in the yellow cells matches that of the row's green cell.
Since column A is non-unique, I need it to operate based on cell references, instead of string matching.
For example, C2 has the value 3 because A2 is referenced twice in the yellow cells, and the corresponding blue cells sum of up to 3 (= F2+F3=2+1). And C4 has the value 0 because A4 isn't referenced once inside the yellow cells, despite having the same string match.
You can try array formula:
=SUM($F$2:$F$10*IFERROR(ADDRESS(ROW(A2),1,4)=SUBSTITUTE(FORMULATEXT($E$2:$E$10),"=",""),0))

I need a RAG formula organising cells less that other cell by 500

What I need help with is a formula to change Red Amber Green when the value of the cell is 500 less than the specified cell. For example
B2 is 3,700 and C2 is 4,000
I need b2 to display as amber because it is within 500 of C2
If B2 is 3,500 or less it needs to be green
And if B2 is 4,000 and greater it needs to be red
If your intention is to set the background colour of cell B2 based on its relationship with cell C2, you'll need to create three Conditional Formatting rules based on formulas as follows:
Fill colour = red with the formula =b2>c2
Fill colour = amber with the formula =c2-b2<=500
Fill colour = green with the formula =c2-b2>500

Conditional formatting a whole column based on the value of another column

I would like to apply conditional formatting to all of my column D. If Column D is < or > then the value in F by 150 (in the same row), I want it to highlight red. If the value of D is within the 150 above of below of the value in F then I want it to highlight green.
For example: D2 (360) is more than 150 more than F2 (88), so I want it to highlight red.
D10 (200) if within the 150 more or less range than F10 (275) so I want it to highlight green.
Below is the picture for the fields
Fields and Data
Format your cells all green. Then apply CF to cells where the difference is greater than 150 to colour those cells red. Here is the formula to use.
=ABS(D2-F2)>150

How do I evaluate true or false for multiple conditions in a list

I feel like this should be easy, but I'm at a loss. I'll do my best to describe example tables to suit my issue.
Table 1: -Cell A1 is labeled color with cells containing either "red", "blue" or "green" -Cell B1 is labled size with sizes ranging from 1 - 10. -Cell C3 is labled "candidate?" These cells will be either 1 or 0 depending on whether or not columns a and b match conditionals from table 2.
Table 2: -Cell E1 is labeled color and cell D1 is labeled size. -Cell E2 is blue, cell D2 is 5 -Cell E3 is red, cell D3 is 2
Basically I need a formula for cells in column C that will tell me if the values in column A match the value in column E and if the value in column B is greater than or equal to the corresponding value in column D.
Thanks for your help!
edit: apologies, I'm using the latest version of excel on a PC.
Actually I figured it out it was
=IFERROR((INDEX($E:$E,MATCH(A2,$D:$D,0))<=B2)*1,0)

Finding combinations and counting them in Excel

I don't know much about Excel and I'm trying to do the following:
So, if a I had column A and column B:
A B
red green
red green
red green
blue pink
blue pink
blue pink
blue pink
black white
black white
Let's say I have hundreds of rows of combinations. What I need to do is on a second sheet, show all the different combinations and the number of times each occurs. So for the above, the result would be:
Combination: Number of times:
red green 3
blue pink 4
black white 2
So, I would need to give me the combination and the number of times it occurs.
Any idea how I could do this?
Make a header into your spreadsheet: A1 = color1, B1 = color2, C1 = combination
1- Type on C2
=A2&"-"&B2
drag the formula down on column C until the last row in which there are data on columns A and B.
2- Go to "Insert" --> "PivotTable"
Drag "combination" into the "Row Labels", and Drag "combinations" into the "Values" label.
You need to have a mathematical operation in the pivot-table "Values" field, and the "Count" operation is already set automatically when one drags a variable into it (so, it should appear "Count of combinations").
Here is a screenshot about how the Pivot Table should look like:
One way you could do this is the following:
Select the entire data, copy it and paste it where you want to calculate the number of occurences. Select that range and in the Data tab select Remove Duplicates. This will get you all unique occurences of patterns.
Now, with the following formula you can get the count of each of those cases. Notice that this is an array formula so when you enter it initially you have to hit Ctrl+Shift+Enter in the formula box for it to calculate properly. Here's the formula, just change the cells to those that match your need:
=SUM(IF($A$1:$A$4&$B$1:$B$4=A1&B1,1,0))
Here,$A$1:$A$4&$B$1:$B$4 concatenates the two columns together to create "keys". It then matches this with the current combination to check (A1&B1) and then returns 0 or 1 and sums the total to get the count.
Add a third column - "Count" - adding the value "1" in each row of this column.
Include this column in your Pivot Table data and then allocate your fields in the Pivot Table as follows:
Columns: A | Rows: B | Values: Count

Resources