I am trying to calculate the number of unique values in A column based on the corresponding values in column B. I should get 3 unique values corresponding to 10 and 1 corresponding to 15.
What I have tried so far?
Let's say 10 is in the cell D2
=SUMPRODUCT((($A$2:$A$5=D2))/COUNTIFS($A$2:$A$5,$A$2:$A$5&"",$B$2:$B$5,$B$2:$B$5&""))
Then using ctrl+shift+enter I've made the formula into array, but I get 0. It is wrong.
Your help is very appreciated.
Related
As I stated in the title, I want to calculate the sum of the first n% rows in a filtered column. The total numbers of rows in the column varies due to the filtering options, so my formula must work with different values of n.
For example :
In column A, I have 10 rows that contain values from 10 to 1 ( I sorted them from largest to smallest ).
In column B, I have 10 corresponding rows that contain 2 names: 4 of them contain the value "Tom", six of them contain the value "Jerry". When I filter the whole table and select only the rows that contain the value "Jerry", I want to be able to calculate the sum of the first 20% of the corresponding 6 number values.
This could work without any filtering if you want.
With criteria for column B in E1 and percentage you looking for in F1 with the assumption we want to round up the percentage to integers.
So formula in D1:
=SUMPRODUCT(LARGE((B2:B11=E1)*(A2:A11),ROW(A1:INDEX($A:$A,ROUNDUP(COUNTIF(B2:B11,E1)*F1,0)))))
So, without your data, I came up with this, edit to suit your situation...
So, based on the comment, I did a second version:
The helper column in col C is used with sumproduct to give the result...
You can use the percentile function in AGGREGATE with SUMIFS to do what you want:
=SUMIFS(A:A,B:B,"Jerry",A:A,">="&AGGREGATE(16,7,A1:A10/(B1:B10="Jerry"),0.8))
If you want to use the filter to do the decision:
=SUMPRODUCT(SUBTOTAL(3,OFFSET(A1,ROW(A2:A10)-1,,1))*(A2:A10>=AGGREGATE(16,7,A2:A10,0.8)),A2:A10)
in column A2:A17 I have numbers list. column B2:B17 date list. Column C contains sections C2:C17.
I want generate unique values belongs to by entering start date to G2 End date to G3 and section to G4. I try below formula works but its get 0 value between generated unique value list if some cells in column A is blank.I need unique values without genter image description hereetting 0 between unique list. some values in column A:A is blank.
=IFERROR(INDEX($A$2:$A$17,MATCH(0,COUNTIF($D$1:D1,IF(($G$3>=$B$2:$B$17)*($G$2<=$B$2:$B$17)*($G$4=$C$2:$C$17),$A$2:$A$17,$D$1)),0)),"")
Give this a try:
=IFERROR(INDEX($A$2:$A$17,MATCH(1,INDEX(($B$2:$B$17>=$G$2)*($B$2:$B$17<=$G$3)*($C$2:$C$17=$G$4)*(COUNTIF(D$1:D1,$A$2:$A$17)=0)*($A$2:$A$17<>""),),0)),"")
Consider this table:
I wish to count the number of unique ITEM occurances, but only add if Quantity of the item is greater than 0.
So in this case, the formula should return B, C and D = 3
In another example, the quantity of B was changed, but the result should still be 3, as I wish to sum only unique values from column "Item".
I am trying to fiddle with this formula, but couldn't figure how to add the "Quantity>0" condition:
=SUMPRODUCT((A1:A7<>"")/COUNTIF(A1:A7;A1:A7&""))
This returns the number of unique values without considering quantity.
Is my goal even possible without VBA?
NOTE:
Table has blank and text values in some Quantity cells. These lines should be ignored by formula.
This formula should work, even with text or blanks in the Quantity column
=SUM(IF(FREQUENCY(IF(ISNUMBER(Quantity)*(Quantity>0),MATCH(Item,Item,0)),ROW(Item)-MIN(ROW(Item))+1),1))
confirm with CTRL+SHIFT+ENTER
=SUM(IF(FREQUENCY(IF(LEN(IF(IF(ISNUMBER(Quantity),Quantity,0)>0,Item,""))>0,MATCH(Item,Item,0)),
IF(LEN(IF(IF(ISNUMBER(Quantity),Quantity,0)>0,Item,""))>0,MATCH(Item,Item,0),""))>0,1))
This is an array formula so should be confirmed by holding down Ctrl + Shift while hitting Enter
Should handle blanks and text in column B.
Column "A" is a numbering column for each Row, some numbers are the same, ie..
A1 is 1
A2 is 3
A3 is 1
A4 is 3
I need a formula that will show how many cells with content are in this column without counting duplicates, as above would be 2. I was figuring an "If-Then" formula but am unable to get it straight. Any help out there? Thank you in advance!
If you're using Excel 2013, I want to say that there's a count distinct function. Nonetheless, you can do it like this:
=SUM(IF(FREQUENCY(A1:A4,A1:A4)>0,1))
EDIT: Adding an explanation. The FREQUENCY function gets the frequency of the unique values within the array A1:A4 (first parameter), binning it using the values within A1:A4 (second parameter). The IF checks to see if that returns anything, i.e. if the frequency is greater than 0, in which case it returns 1 for each unique value it finds. Then the SUM adds the number of 1s returned by the IF statement, in turn giving you the number of unique values within the array A1:A4.
Currently I have a formula that just counts the unique values in a column:
=SUM(IF(FREQUENCY(A2:A10,A2:A10)>0,1))
However, I'd only like to count them if a corresponding cell in the same row has a certain value. Is this possible without using VBA?
For example:
A B
1 Old
1 Old
2 New
2 New
3 Old
3 New
4 New
I want to get the count of unique values of the A cells that correspond to the "New" value in the B col. So the unique occurrence count in A for "New" would be 3
Have been looking over excel references and not seeing how I would do this with ranges of data.
You can use this formula
=SUM(IF(FREQUENCY(IF(B2:B10="New",A2:A10),A2:A10),1))
confirmed with CTRL+SHIFT+ENTER