Can I create a COUNTIF calculated column in SharePoint?

Whozumommy picture Whozumommy · Jun 10, 2009 · Viewed 56.6k times · Source

Is there a way to create a SharePoint calculated column that returns a count of the number of entries in a list? So If I have 3 customers in my list with the company "Starbucks" I'd like the field to return "3"

Answer

Sam Yates picture Sam Yates · Jun 11, 2009

(Edited some wording for clarity per suggestion from dariom).

You may be able to get what you want with another list using a not-so-well-known variation of a lookup column.

Let's say you have a list called Companies with values in the title column like "Starbucks", "Peets", etc. Now you also have the Customers list you refer to, but the "Company" column is a lookup column pointing to the title column in the Companies list.

You can add a count very similar to what you described to your Companies list. Go to your Companies list, add a column of type "Lookup" referring to the Customers list and you'll notice that in the drop-down area where you define the lookup if you point back to the Customers list, you'll have a new option called "Count Related". This is here automatically because it recognizes that the Customers list has a lookup pointing back to this one. Select that Count Related option and now your Companies list will have a column counting how many customers are associated with that company.

No coding, Javascript hacks, or anything. Just hidden SharePoint auto-magic. Column Related