count data using two columns as references - excel

Is it possible to count or countif by using a column as the data, a cell for the criteria (or what to match) and range of what to count?
Here is what I am looking at:
A1 B C D E F G H I J K L M N O
2 Running Data Total Count of Tardies (by category)
3 Date Employees Leader Start of Shift Break 1 Lunch Break 2 Employees Start of Shift Break 1 Lunch Break 2 Total
4 1-Jul Abe Sue 15 Abe 0
5 3-Jul Steve Bob 20 Anna 0
6 5-Jul Eve Andy 9 20 Eve 0
7 7-Jul Anna Andy 30 Helen 0
8 15-Jul Abe Sue 15 Mark 0
9 18-Jul Anna Andy 10 Steve 0
10 20-Jul Helen Sue 9 0
11 31-Jul Mark Bob 45 0
I am trying to count the data entered on the left (running data) in each category and having it show based on the Employees on the right (in the orange cells). So Abe should show 1 for Start of Shift, Eve should show 1 for Break 1 and Break 2, and Anna should show 2 for Start of Shift.
I have tried using:
=countif(C:C,$J4,D:D) to get the data from JUST Column D for Start of shift, but it gives and error saying too many arguments for the function have been entered.
Help...
...and Thanks!

Countif will only look at 1 column to decide what to count.
Countifs will look at multiple columns. Your formula would look something like this:
=COUNTIFS($C:$C,$J4,E:E,">0")

Related

Count rows where two values appear together

My data are in MS Excel:
Col A Col B Col C Col D
1 amy john bob andy
2 andy mel amy john
3 max andy jim bob
4 wil steve andy amy
So, in 4x4 table there are 9 different values.
I need to create table to find how many times each PAIR is occurring in the same ROW. Something like this:
amy andy bob jim john max mel steve will
amy 0
andy 3 0
bob 1 2 0
jim 0 1 1 0
john 2 2 1 0 0
max 0 1 1 1 0 0
mel 1 1 0 0 1 0 0
steve 1 1 0 0 0 0 0 0
will 1 1 0 0 0 0 0 1 0
And I have no clue how to do it...
To reiterate: no duplicated values in each row, each row has unique values, each value in separate cell, so there are column with values and within column values can duplicate.
Any help will be much appreciated!
Assuming your data is in A5:D8 I proceeded like this -
created a helper column with the formula (copied downwards)
=A5&"-"&B5&"-"&C5&"-"&D5
Named this helper column as helper (named range)
listed down and across the unique combinations of names in H4:P4 (across) and G5:G13 (down)
enter this formula in H5 and copy it both downwards and across to fill all 9x9 matrix
=IF($G5=H$4,0,COUNTIFS(helper,"*"&$G5&"*",helper,"*"&H$4&"*"))
Your desired matrix is ready
A detailed blog is available on web for this.

Group by name and count unique values

I have an Excel file like this, where column A and B are given. I want to add column C and D that represent days. D is pretty easy, because it is always one day. C is tricky, because I want to count only "unique" days, where a branch can be one day maximum, where D counts all days.
A B C D
Row Name Branch Unique Overall
1 Jack Health 1 1
2 Jack Health 0 1
3 Jack Food 1 1
4 Jolie Tech 1 1
5 Jolie Food 1 1
6 Jolie Tech 0 1
7 Jolie Health 1 1
I need column C and D for a pivot table like this:
Branch Unique Overall
Health 2 3
Food 2 2
Tech 1 2
I also could add names as a sub position.
Branch Unique Overall
Health 2 3
-Jack 1 2
-Jolie 1 1
Food 2 2
-Jack 1 1
-Jolie 1 1
Tech 1 2
-Jolie 1 2
But that´s something, that can be done after preparing the data and what comes with the program anyway. So how can I design a formula that counts only unique branches for a data set of hundreds of rows?
Thank you!
In C2 put:
=--(COUNTIFS($A$2:A2,A2,$B$2:B2,B2)=1)
Then copy down

Finding MAX value using VLOOKUP with many duplicate "IDs"

Using an Excel formula, I'm trying to pull the MAX value for a NAME that has a certain LETTER next to it.
Eg: Highest # for a specific % for each unique Name
So Jeff's Q value would be 7.
(I'm trying to over explain because it makes sense in my mind but it might not make sense to others..)
Name % #
Jeff O 4
Jeff D 3
Jeff Q 4
Jeff O 1
Jeff D 9
Jeff Q 7
Tom O 6
Tom D 7
Tom Q 8
Tom O 2
Tom D 8
Tom Q 3
Peter O 3
Peter D 8
Peter Q 7
Peter O 4
Peter D 10
Peter Q 3
Bob O 2
Bob D 6
Bob Q 10
Bob O 6
Bob D 10
Bob Q 9
Mark O 4
Mark D 7
Mark Q 4
Mark O 7
Mark D 8
Mark Q 1
I can't think of a way to run this without having dedicated worksheets for each person and running MAX on the specific column.
I've tried IF, VLOOKUP and MAX in various configurations but I get nothing.
Has anyone got any experience with this and could please point me in the right direction?
The MAXIFS function should be what you want. For example, assuming that you have your data in columns A:C the formula
=MAXIFS(C:C,A:A,"Jeff",B:B,"Q")
will give you the max number in column C where the value in row A is "Jeff" and the value in row B is "Q".

Allocate class based on school ranking

In Excel I am trying to allocate classes to pupils based on their ranking in school. The set of data I have looks like this:
S/N Name LevelPosition
1 Andrea 10
2 Bryan 25
3 Catty 5
4 Debbie 26
5 Ellie 30
6 Freddie 28
I would like to have a formula that could sort the pupils based on the LevelPosition and allocate the class in order of this sequence - A,B,C,C,B,A. Hence the result would be:
S/N Name LevelPosition AllocatedClass
3 Catty 5 A
1 Andrea 10 B
2 Bryan 25 C
4 Debbie 26 C
6 Freddie 28 B
5 Ellie 30 A
This was the sort of thing I had in mind.
Column D is just a ranking from bottom to top:-
=RANK(C2,C$2:C$7,1)
Colum D is adjusted for any ties:-
=D2+COUNTIF(D$1:D1,D2)
Column E is based on the #pnuts formula:-
=CHOOSE(MOD(E2-1,6)+1,"A","B","C","C","B","A")
I've put some ties in to show what would happen. The last two students' allocations are reversed because the second to last has the higher mark.

Get Top Performer by Subgroup Using Index and Match

I am trying to rank names in Column C from largest to smallest score.
Category Score Name Total Rank Apple Rank Orange Rank
Apple 10 Joe Rachel Rachel 0
Orange 15 Don Natalie 0 Natalie
Apple 20 James Tom Tom 0
Apple 1 Rob Nothing Nothing 0
Orange 3 Mary Gina 0 Gina
Orange 100 Rachel James 0 James
Orange 99 Natalie Don 0 Don
Orange 87 Tom Joe 0 Joe
Apple 27 Gina Mary Mary 0
Orange 30 Nothing Rob 0 Rob
This works in Column E for Apples AND Oranges, with formula in E2 that is
=INDEX($C$2:$C$25,MATCH(1,INDEX(($B$2:$B$25=LARGE($B$2:$B$25,ROWS(E$1:E1)))*(COUNTIF(E$1:E1,$C$2:$C$25)=0),),0))
However, the goal is to compare Apples to Apples and Oranges to Oranges.
Only, the formulas in Columns F and G show "0" values for those rows that aren't in the right Apple/Orange category.
For F2:
=IF($A:$A="Apple",INDEX($C:$C,MATCH(1,INDEX(($B:$B=LARGE($B:$B,ROWS(F$1:F1)))*(COUNTIF(F$1:F1,$C:$C)=0),),0)),0)
For G2:
=IF($A:$A="Orange",INDEX($C:$C,MATCH(1,INDEX(($B:$B=LARGE($B:$B,ROWS(G$1:G1)))*(COUNTIF(G$1:G1,$C:$C)=0),),0)),0)
How do I modify the codes so that 0 values won't show up?
Something like this would be great: (screenshot made by just copy pasting values...)
Apple Rank Orange Rank
Rachel Natalie
Tom Gina
Nothing James
Mary Don
Joe
Rob
Note: Unless the whole column ranges are required the steps below may seem to take an uncomfortably long time if these ranges are not restricted.
Assuming you have what below is in ColumnA:G and a corresponding layout:
then ColumnsI:J may be achieved quite simply by copying ColumnF:G and Paste Special..., Values into I1, then select ColumnsI:J, HOME > Editing - Find & Select, Replace..., Find what: 0, Replace with: , Replace All followed by Find & Select, Go To Special..., select Blanks (only), OK, right-click on one of the chosen cells and Delete..., Shift cells up, OK.
To remove the 0s from ColumnF:G only replacing the final 0 in each formula with "" is sufficient.

Resources