Excel: Count Only Once If Another Column Has Duplicates - excel

I am trying to create a formula that will count the number of "Overdue" people instead of "Overdue" cells. Each person has the multiple rows with their name in it. The criteria to determine if it's "overdue" is:
-Column F and G are not within 3 years
-Column G are blank
-Column F = 0 and Column G are not within 3 years
The following code counts the criteria accurately. And doesn't account for duplicate names.
=SUM(COUNTIFS(TT[Fiscal Law 301 CBT],"<"&TODAY()-1065,TT[Fiscal Law 301 CBT],">"&TODAY()-1095,TT[Fiscal Law In-Residence],"<"&TODAY()-1065,TT[Fiscal Law In-Residence],">"&TODAY()-1095),COUNTIFS(TT[Fiscal Law In-Residence],"",TT[Fiscal Law 301 CBT],"<"&TODAY()-1065,TT[Fiscal Law 301 CBT],">"&TODAY()-1095))
The formula I want should count based on the criteria above and check column Z TT[Name] for duplicates and count them only once. And also count unique values once.
I just thought of another approach to this problem. What if I use the formula I have to create an Array, have another formula count the number of duplicates in Column Z from that Array, and subtract the two numbers.
This way should get me the correct number, i will still need assistance creating the second formula.

What you are after is a distinct count. Excel has a function for that in the new Dynamic Array function set, which is in Office 365 Insider builds but not available to everyone. Right now, a distinct count requires a few tricks.
For example, you can create a pivot table with the names in the rows, filter the table to include only values where column X = Overdue and use a CountA() on the result rows.

You are close, but not quite there.
Use a countifs formula like above. Then, create a column next to it with the logic if(countcell>0, 1, 0). This will return 1 if the person has at least 1 book overdue, and 0 otherwise. Then, take the sum of that column.
Formulas
I have provided a screenshots of the code that we would use (the E and F columns are dates). As you can see, the G column counts how many books are overdue. The H column provides a 1 if at least 1 book is overdue for each user. Then, we can simply sum the H column to find the total number of users with overdue books.
If this helps you, please consider choosing this as the answer.

Related

Only show the sum of a column if there are at least 3 records in another column

I have 3 Columns of data. Column E = Duration. The user will enter a number of days (Duration) for 20 employees. Column F = Pay. List of wage for each employee. Column R = Pay Total. This is a calculated field based on the number of days (Duration) and the employees pay (Pay).
To keep my employees from finding out their coworkers pay I only want to see a sum for Column C if there are at least 3 records in Column A.
I found this Sum only if 3
From that answer I tried to use =IF(COUNTIF(E2:E15,">2"),SUM(R2:R15))
What this does is only returns records with a duration of greater than 2 days. I don't care about the number of days. I want the indicator to be that there are 3 cells populated in this column.
I think the only issue with the formula is the CountIF part. I need to know what I should use to count cells not days.
Screenshot of My Sheet
In the image above you can see that it's returning a sum bc both records are greater than 2. Like I said before I don't care what number is in the cell I just want to see the sum if there are more than 2 cells populated in that column.
Thanks for any help
As per my understanding of the question, I came up with this solution. Give it a try.
=IF(COUNT($E$2:$E$15)>2,SUM($R$2:$R$15), 0)
This formula would give what you want
=IF(COUNTA(E2:E15)>2,SUM(R2:R15),"")
This would show sum only if count of non empty cells is greater than 2 in Range "E2:E15" else it would show empty.

Index/match if greater than

Hoping someone can help me with my trouble with an index/match formula.
Column B has a list of names, column C has the frequency of an action taken (sales made) whilst column D has the average sales value.
I've created in column G a track of the 6 highest sales which has worked great:
=LARGE($D$8:$D$13, 2)
Then I've used column F to determine the name that matches each sales average:
=INDEX($B$8:$B$13, MATCH(G4, $D$8:$D$13, 0))
So far so good! However, I'd like to only include the sales average if that individual has had more than 3 sales. IE; the value in column C is >3.
Can any one provide help or suggestions please?
I think you could use a helper column to filter out the values you don't need before applying =LARGE() in the very beginning, like this:
=IF($C8>3, $D8, "")
Then do =LARGE() to this column instead:
=LARGE($X$8:$X$13, 2)
You could use an array formula:
=LARGE(IF(range=criteria,values),n)
so for your case:
=LARGE(IF($C$8:$C$13>3,$D$8:$D$13), 2)
press CTRL+SHIFT+ENTER to enter an array formula.

Ranking in Excel with multiple criteria

For example, I need to create a merit list of few student based on total marks (column C), then higher marks in math (column B) -
A B C D
-------------------------
Student1 80 220 1
Student2 88 180 3
Student3 90 180 2
Expected merit position is given in column D.
I can use RANK function but I can only do that for one column (total number). If total number of multiple student is equal, I could not find any solution of this.
You can try this one in D1
=COUNTIF($C$1:$C$99,">"&C1)+1+SUMPRODUCT(--($C$1:$C$99=C1),--($B$1:$B$99>B1))
and then copy/fill down.
let me know if this helps.
Explanation
Your first criteria sits in column C, and the second criteria sits in Column B.
Basically, first it is counting the number of entries ($C$1:$C$99) that are bigger than the entry itself ($C1). For the first one in the ranking, you will get zero, therefore you need to add 1 to each result (+1).
Until here, you will get duplicate rankings if you have the same value twice. Therefore you need to add another argument to do some extra calculations based on the second criteria:
To resolve the tie situation, you need to sumproduct two array formulas and add the result to the previous argument, the goal is to find the number of entries that are equal to this entry with $C$1:$C$99=C1 and have a bigger value in the second criteria column $B$1:$B$99>B1:
you add -- to convert TRUE and FALSE to 0s and 1s so that you can multiply them:
SUMPRODUCT(--($C$1:$C$99=C1),--($B$1:$B$99>B1))
the first array is to see how many ties you have in the first criteria. And the second array is to find the number of bigger values than the entry itself.
Note you can add as many entries as you like to your columns, but remember to update the ranges in the formula, currently it is set to 99, you can extend it to as many rows as you want.
Sometimes a helper column will provide a quick and calculation-efficient solution. Adding the math marks to the total marks as a decimal should produce a number that will rank according to your criteria. In an unused column to the right, use this formula in row 2,
=C2+B2/1000
Fill down as necessary. You can now use a conventional RANK function on this helper column like =RANK(D2, D$2:D$9) for your ranking ordinals.
Very simple (or, at least, much more simpler that the one provided by the best answer) 'math' solution: do a linear combination with weights.
Do something like
weighted_marks = 10*colC + colB
then sort weighted marks using simple rank function.
It does solve your problem, bulding the ranking you need.
If you don't like to limit the number of rows or the numbers used in the criteria, Jeeped's approach can be extended. You can use the following formulas in cells D2 to L2, assuming that there are three criteria, the first one in column A, the second one in column B, and the third one in column C:
=RANK($A2,$A:$A,1)
=RANK($B2,$B:$B,1)
=D2*2^27+E2
=RANK(F2,F:F,1)
=RANK($C2,$C:$C,1)
=G2*2^27+H2
=RANK(I2,I:I,1)
=J2*2^27-ROW()
=RANK(K2,K:K,0)
The formulas have to be copied down. The result is in column L. Ties are broken using the row number.
If you like to add a fourth criterion, you can do the following after having the formulas above in place:
Add the new criterion between columns C and D.
Insert three new columns between columns I and J.
Copy columns G:I to the new columns J:L.
Copy column G to column M, overwriting its content.
Change the formula in column L to point to the new criterion.
The factor 2^27 used in the formulas balances the precision of 53 bits available in double-precision numbers. This is enough to cover the row limit of current versions of Excel.

Excel counting pairs

I have 5000 rows. In column A I have the salesperson , in column B the buyer. I am trying to find out how many times each combination appear together. e.g. Did salesman Abe sell to Buyer Bob 33 times, to buyer Carl 19?
ok takes a few extra columns to accomplish this but here goes...screenshot attached first.
First you need to concatenate the two columns (A and B)you want to enumerate in column C (the formula will accommodate a string in case names column is first last with spaces etc.)
=$A2&" "&$B2
Then in column D use the following formula to determine whether or not the name combination is duplicated but only true for one instance. I'll explain why in a second.
=$C1<>$C2
Then in column E count the matches.
=COUNTIF($C:$C,$C2)
After doing all that, filter results by "True" tally for all the True columns is the number of matching rep/customer relationships.

How to implement a count if and index or match function in Excel

I am working on a template which records actions of specific companies during an auction. In Column J I have actions, and column K I have the company name. What I need help with is integrating a function to check the validity of a specific action. Essentially You cannot have an action of neg in column J without an action of bid in column J for a specific firm.
So I am trying to use conditional formula to create a check to see if for a given firm in column K is the count of neg less than the count of bids for the same firm in column J
These are the column names, the actions themselves are all in the same clump.
How many actions do you have? If there are not many you could add a column for each action with a count.
For example, add a column called Compare_1 in column L and a column called Compare_2 in column M.
In column L create a countifs formula (I started in Row 3, if your data starts in row 2 you would change K3 to K2)
=COUNTIFS(K:K,K3,J:J,"neg")
You can also modify the formulas to incorporate each type you need to compare in Compare_1 and then do the same in the next column for the Compare_2 data.
=IF(OR(J3="neg",J3="bid"),(COUNTIFS(K:K,K3,J:J,"neg")),IF(OR(J3="dog",J3="puppy"),(COUNTIFS(K:K,K3,J:J,"dog")),0))
and in column M create a countifs formula
=COUNTIFS(K:K,K3,J:J,"bid")
Then create a validation column in column N with the formula
=IF(L3=M3,"Valid","Not Valid").
Again to combine for Compare_2
=IF(OR(J3="neg",J3="bid"),(COUNTIFS(K:K,K3,J:J,"bid")),IF(OR(J3="dog",J3="puppy"),(COUNTIFS(K:K,K3,J:J,"puppy")),0))
There could be an easier 1 step process from someone else, but this is what I came up with.

Resources