Solved

Ms Excel: How to count different variations of text

Posted on 2011-09-08
6
916 Views
Last Modified: 2012-05-12
Good morning Excel Gurus,
I want to know if there is a custom function i could use to count variations in text.  For example I have a set of numbers in one column and in column two the definition of the numbers. so for example.

1  Reason abc
1  Reason def
1  Reason abc
1  Reason hij
1  Reason abc
 
So my count of Reason abc = 3, def = 1, hij=1
For number 1=3 distinct reasons
I know I could throw into a pivot table and count this way. I was hoping to be able to use a function to accomplish the same task.

Thanks
PS

OptxtExample.xlsx
0
Comment
Question by:BajanPaul
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 56

Accepted Solution

by:
Bill Prew earned 250 total points
ID: 36503274
Where do you want the count to appear?  If you just want it next to each row, you can do this with the COUNTIF function.  But I suspect you are looking for more of a summary table of just the unique labels, and their counts.  In that case a pivot table is the way to go, and better suited than a custom VBA function.

~bp
0
 
LVL 24

Assisted Solution

by:StephenJR
StephenJR earned 250 total points
ID: 36503310
The point about a pivot table is that it will generate the unique list of reasons for you.
0
 

Author Comment

by:BajanPaul
ID: 36503355
The example attached just has 1 number in it.  The data set I am working with has 209 distinct numbers.  I want to incorporate a look up by number and count the unique text values.
So for example:
Num       DistinctTxtCounts
1            136
2            154
3            29
4            18
11          34
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 4

Expert Comment

by:grogman
ID: 36503416
OK, so if I am understanding, you have a list of numbers, and you want to find out how many times each individual number appears in the list. One way to do something like this would be with what I used to call an 'array' function.

Let us say that in cells A1:A500, you want to count how many times the number '344' appears. You could use a formula such as this:

=SUM(IF($A$1:$A$500=344,1,0))

IMPORTANT NOTE! When entering this formula, you MUST hit CTRL+SHIFT+ENTER, not just ENTER. This tells Excel that the function you are entering is an array function (referencing an array of cells). You will know if you entered it correctly by clicking on the cell containing the formula and looking at the formula bar. The formula will look like this in the formula bar:

{=SUM(IF($A$1:$A$500=344,1,0))}

The brackets signify that it is an array function. You cannot type the brackets, you must use CTRL+SHIFT+ENTER to force Excel to do this.
0
 
LVL 4

Expert Comment

by:grogman
ID: 36503433
Explanation: The array forumula cycles through the array of cells, and utilizing the IF statement, interprets each cell containg the number you are looking for as a value of "1", and each of the non-matching cells as a value of "0". The SUM function then adds up all of the 1's and 0's, giving you your count.
0
 

Author Closing Comment

by:BajanPaul
ID: 36503443
Gents,

I appreciate the feedback.  I chose to use excels remove duplicates function and then passed the data into an excel pivot for the counts.

THanks
0

Featured Post

Three Considerations for Containers

Containers like Docker and Rocket are getting more popular every day. In my conversations with customers, they consistently ask what containers are and how they can use them in their environment. If you’re as curious as most people, read our article on Experts Exchange.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

With User Account Control (UAC) enabled in Windows 7, one needs to open an elevated Command Prompt in order to run scripts under administrative privileges. Although the elevated Command Prompt accomplishes the task, the question How to run as script…
If you need to forecast numbers -- typically for finance -- the Windows and Mac versions of Excel 2016 have a basket of tools to get the job done.
This Micro Tutorial will demonstrate in Google Sheets how to use the HYPERLINK function to create live links inside your spreadsheet.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

631 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question