Count digits and ignore duplicates
I have a question that I can’t seem to find an answer to:
I want to make a full count of digits 0 to 9 while ignoring duplicates in any line
B Â Â Â C Â Â Â D Â Â Â E
5 Â Â Â 5 Â Â Â 5 Â Â Â 5
8 Â Â Â 6 Â Â Â 7 Â Â Â 4
6 Â Â Â 2 Â Â Â 8 Â Â Â 7
7 Â Â Â 7 Â Â Â 1 Â Â Â 6
5 Â Â Â 6 Â Â Â 6 Â Â Â 2For example, with the digits shown above, my results for the count will be:
0=0; 1=1; 2=2; 3=0; 4=1; 5=5; 6=4; 7=3; 8=2; 9=0
The formula below does not work for the “5” count since it counts all the occurrences:
=COUNTIF($B$1:$E$5,5)
Answer:
I can't achieve the desired result for number 5. I calculated any line as "in any row" and "in any column". I guess the desired result for number 5 is a typo.
Array formula in cell B9:
Copy cell B9 and paste down as far as needed.
Array formula in cell C9:
Copy cell C9 and paste down as far as needed.
How the formula works in cell B9
Step 1 - Find digit in array
=SUM(IF(FREQUENCY(IF(A9=$B$1:$E$5, ROW($B$1:$E$5)-MIN(ROW($B$1:$E$5))+1, ""), ROW($1:$5))>0, 1, 0))
A9=$B$1:$E$5
becomes
0={5, 5, 5, 5;8, 6, 7, 4;6, 2, 8, 7;7, 7, 1, 6;5, 6, 6, 2}
becomes
{FALSE, FALSE, FALSE, FALSE;FALSE, FALSE, FALSE, FALSE;FALSE, FALSE, FALSE, FALSE;FALSE, FALSE, FALSE, FALSE;FALSE, FALSE, FALSE, FALSE}
Step 2 - Convert boolean array to row numbers
=SUM(IF(FREQUENCY(IF(A9=$B$1:$E$5, ROW($B$1:$E$5)-MIN(ROW($B$1:$E$5))+1, ""), ROW($1:$5))>0, 1, 0))
IF(A9=$B$1:$E$5, ROW($B$1:$E$5)-MIN(ROW($B$1:$E$5))+1, "")
becomes
IF({FALSE, FALSE, FALSE, FALSE;FALSE, FALSE, FALSE, FALSE;FALSE, FALSE, FALSE, FALSE;FALSE, FALSE, FALSE, FALSE;FALSE, FALSE, FALSE, FALSE}, {1, 2, 3, 4}, "")
becomes
{"", "", "", "";"", "", "", "";"", "", "", "";"", "", "", "";"", "", "", ""}
Step 3 - Count row numbers
=SUM(IF(FREQUENCY(IF(A9=$B$1:$E$5, ROW($B$1:$E$5)-MIN(ROW($B$1:$E$5))+1, ""), ROW($1:$5))>0, 1, 0))
FREQUENCY(data_array, bins_array)
Calculates how often values occur within a range of values and then returns a vertical array of numbers having one more element than Bins_array.
FREQUENCY(IF(A9=$B$1:$E$5, ROW($B$1:$E$5)-MIN(ROW($B$1:$E$5))+1, ""), ROW($1:$5))
becomes
FREQUENCY({"", "", "", "";"", "", "", "";"", "", "", "";"", "", "", "";"", "", "", ""}, {1; 2; 3; 4; 5})
becomes
{0; 0; 0; 0; 0}
Step 4 - Count numbers larger than zero
=SUM(IF(FREQUENCY(IF(A9=$B$1:$E$5, ROW($B$1:$E$5)-MIN(ROW($B$1:$E$5))+1, ""), ROW($1:$5))>0, 1, 0))
becomes
=SUM(IF({0; 0; 0; 0; 0}>0, 1, 0))
becomes
=SUM({0; 0; 0; 0; 0}) and returns 0 (zero).
Count values category
This post demonstrates how to build an array formula that counts unique distinct values based on criteria. What's on this […]
This article explains how to count cells highlighted with Conditional Formatting (CF). The image above shows data in cell range […]
This article describes how to count unique distinct values. What are unique distinct values? They are all values but duplicates are […]
Excel categories
2 Responses to “Count digits and ignore duplicates”
Leave a Reply
How to comment
How to add a formula to your comment
<code>Insert your formula here.</code>
Convert less than and larger than signs
Use html character entities instead of less than and larger than signs.
< becomes < and > becomes >
How to add VBA code to your comment
[vb 1="vbnet" language=","]
Put your VBA code here.
[/vb]
How to add a picture to your comment:
Upload picture to postimage.org or imgur
Paste image link to your comment.
I know a formulas
1*30*(5+7)/2*(0.90+0.70+0.60)/3 =
Please send a formula in my email
January 17th, 2012 at 7:26 pm
I know a formulas
1*30*(5+7)/2*(0.90+0.70+0.60)/3 =
Please send a formula in my email