Counting "Company Names" in a Numbers Column

I have a column with various company names and they may be repeated eg


ACME Inc

Delta Products

Wazho Partners

Onya Mate Services

Grand Poobar Association

Delta Products

ACME Inc

Wazho Partners

Delta Products

Safari Tours

Onya Mate Services

Number One Inc

ACME Inc

Delta Products



They will each be mentioned multiple times in that column.


I'd like to do a calculation that tells me the total number of unique companies listed in that column

eg based on the list above, I need to know that there are seven unique companies listed... I don't care who they are nor how many times they are listed...


Then optionally, and as seperate calculations if required, I'd be interested to know how many times each individual company is mentioned in that column

eg based on the list above, I'd like to know that ACME Inc is mentioned 3 times, while Delta Products are mentioned 4 times, Wazho are mentioned twice and the others are mentioned once each


And while I'm at it, I have some companies colour coded (as the text colour, not the cell colour) for various reasons...

Is it possible to calculate how many are coloured "Tangerine" and how many are "Clover"???

[I'm not expecting this one to be possible, but thought I'd ask anyway]




Posted on Feb 2, 2025 7:51 AM

Reply
Question marked as Top-ranking reply

Posted on Feb 2, 2025 8:43 PM

Hi Nicholas,


Thank you for pasting your data (instead of a screen shot). That allowed me to see exactly what you see. Surprise! Trailing spaces after Delta Products and two trailing spaces in Row 7. So there are 8 "unique" companies.



Formula in B2 is COUNTIF(A$1:A2,A)

Formula in Footer B16 is COUNTIF(B,1)


The TRIM function is your friend.

From the Function Browser (the panel on the right):

The TRIM function returns a string based on a given string, after removing extra spaces.

TRIM(source-string)

source-string: Any value from which to remove extra spaces.

Notes

  • TRIM removes all spaces before the first character, all spaces after the last character, and all duplicate spaces between characters, leaving only single spaces between words.


Formula in D2 is TRIM(A2)

Now the occurrences are correct (Column E).


Is that sufficient to answer your first 2 questions?


Your third question: the short answer is no. Numbers does not recognise text colour or any formatting in formulas. However, If you tell us your rules for setting the text colour, we may be able to help.


Regards,

Ian.



7 replies
Question marked as Top-ranking reply

Feb 2, 2025 8:43 PM in response to NicholasPyers

Hi Nicholas,


Thank you for pasting your data (instead of a screen shot). That allowed me to see exactly what you see. Surprise! Trailing spaces after Delta Products and two trailing spaces in Row 7. So there are 8 "unique" companies.



Formula in B2 is COUNTIF(A$1:A2,A)

Formula in Footer B16 is COUNTIF(B,1)


The TRIM function is your friend.

From the Function Browser (the panel on the right):

The TRIM function returns a string based on a given string, after removing extra spaces.

TRIM(source-string)

source-string: Any value from which to remove extra spaces.

Notes

  • TRIM removes all spaces before the first character, all spaces after the last character, and all duplicate spaces between characters, leaving only single spaces between words.


Formula in D2 is TRIM(A2)

Now the occurrences are correct (Column E).


Is that sufficient to answer your first 2 questions?


Your third question: the short answer is no. Numbers does not recognise text colour or any formatting in formulas. However, If you tell us your rules for setting the text colour, we may be able to help.


Regards,

Ian.



Feb 3, 2025 10:34 PM in response to NicholasPyers

NicholasPyers wrote:

The answer should be 7... not 14... based on the "sample data" I provided


And in the screenshot I posted the Pivot Table is on the right and clearly shows 7!


If you have too many to count easily the way you can in the example, just choose another option within the Pivot Table as Camelot has illustrated.


Or even easier, just select the visible cells in that column of the Pivot Table and look down at the bottom of the Numbers window where you will see COUNTA.



Pivot Tables are easy to use, and powerful.


More on Pivot Tables here (also at Help > Numbers Help in your menu):


Intro to pivot tables in Numbers on Mac - Apple Support


Another approach is to use an 'Is Distinct' filter.





With the powerful built-in functionality in recent versions of Numbers the old formula-based solutions for tasks like this are no longer necessary.


SG







Feb 3, 2025 11:54 AM in response to NicholasPyers

Play a little with the Pivot Tables. They're super powerful for summarizing data.


In this case, SG's example showed the values being counted, which is the default, but not the only option.


Just click the (i) icon beside the 'Company (Count All)' field and you'll see other options:



Switching it to 'Count (Unique)' will give you a count of unique values.

Feb 3, 2025 5:50 AM in response to Yellowbox

The "data" above was "dummy" info, hand typed in to give you an idea what I'm working with.

In reality there are over 250 entries... with real organisation names.


That said I'll certainly look at using the trim function to ensure there are no trailing spaces.


And Yes, once I realised I had to change the Column references to Column B in my actual spreadsheet, I'm getting the totals I need... so thanks for that.


As to colours I manually highlight them...


Clover is used if the organisation as "used Product A" and Tangerine is used if the organisation is located outside a particular location. I also use Bold to show successful transactions and Strikethrough for unsuccessful transactions. A row could have both a Colour and Text Style applied to them (or none at all)

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Counting "Company Names" in a Numbers Column

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.