Can I create a COUNTIF calculated column in SharePoint? - sharepoint

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"

(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.

No, I don't think there's a way to do this using the out-of-the-box calculated column.
Some other ways you could accomplish this are:
Create a view for your list that with a group by on the company field and include the total count. This is easiest, but might not be exactly what you're looking for.
Create a custom column type that executes a CAML query to find items that you're interested in. There is a learning curve if you've not done it before and if the list that you're adding this custom column to has lots of rows, you'll be executing a query for each row which is inefficient - it'll be OK for a small number of rows.
Use an event handler on the list that updates a column value each time a new item is added or removed from a list. This is easier, but can also be inefficient if you have a large number of items in your list.

As dariom said (damn my slow typing skills, +1!), only the current row can be operated on with calculated columns by default in SharePoint. There are a couple of documented workarounds involving SharePoint Designer or jQuery, though.

You can get a Count of specific list items in an XSLT Data View
To do this you will need SharePoint Designer.
Right click on your SharePoint List view (ensure the list view contains the field you want to filter by) select convert to XSLT Data View. Then in the Data Source Windows select Data Source Tab and drag and drop the field you want to get a total on for the specific items into where you want it displayed in your XSLT Data View. Click on the numerical value that is showing you should get a lightening bolt icon, select the drop down and choose Count, then select again and choose Filter. Select "Click here to add a new clause" then choose your field name again and enter your unique value as Starbucks and click OK, you can repeat this process for other fields you want the totals on. You will now see the total number of Starbucks items in the list.

I got something similar to work in a way similar to Niall. Basically, I:
Based on the source list, created a Data View Web Part (DVWP) on a "test" web
part page.
Added the footer column, which gives a count.
Set the filter for my conditions (i.e., the items I want to count).
In the code, deleted the recurring items row.
I was left with just the footer, which displayed a filtered count for all the list items. I further customized the footer by taking out the shaded background. Finally, I exported this web part and imported it onto the page where I wanted users to see a total of items in the list (which met the criteria).

Related

How to keep the Cognos List structure?

I have this list with some Grouped columns and with some non grouped columns as well as some List Header and Footer.
I also have some automatic created TOTALS for some of the metrics as well as some manually created totals for some metrics.
QUESTION : I now simply need to REPLACE a metric on the report by another metric. Problem is that the list displays automatic totals for some of the metrics including the one i need to replace so i want to know if it will break (destroy) the structure of my list and will i need to recreate its structure or is there a way to replace the metric without affecting my list sttucture, therefore no need to recreate my totals
Regards !
I believe you can go to the query for the list
In the query, find the data item
Change the expression definition to the new thing you want
Change the property for the name & label too
This way you do not have to adjust the layout

Excel - Find all items that share a common cell value

I am wanting to search this list:
The goal is to determine what all is inside Basket 1, determine which item of those costs the most, and return the color of that specific item. My brain is having a hard time determining the right path for this.
With a Pivot Table, you can resume data based on basket # and then filter by most valuable item, and get the color.
The set up for this Pivot Table is all fields into Rows Section, except Amount that will go into values.
NOTE: Even if my Excel language is different than yours, options I'm using should be in the same position. But anyways, besides set up from the image above, you need to apply a value filter (not label filter!), to field ID and make sure choose option TOP 10 and set it to show just TOP 1
If you just want the most expensive item, ignoring Basket #, just remove field Basket from your Pivot Table, and it will work.
Actually you could have 2 Pivot Tables, each one set up in a different way (all baskets, or each basket).

Create Notes view for duplicate parent documents

We have an Xpages application and recently discovered an issue where there are several Notes documents that have duplicates but the duplicates are PARENT documents too and NOT response documents. Is it possible to create a Notes view that will show duplicates where all the duplicates are parents? I know the formula for showing conflicts is the following but what about where they are all parents?
SELECT #IsAvailable($Conflict)
Expounding on my comment:
Create a view which is categorized on the first column
In the first column formula, put in criteria that you would use to determine a duplicate. This may be the Document Unique ID, or maybe another field or combination of fields.
Add a second column that contains the number 1. Then enable column totals on this column.
Now look at this view you created. With the view categories collapsed, look for any number greater that 1 to determine which documents are duplicates.
I think what you are asking is not how to identify the duplicates - but how to find out which of them are parent documents. So basically you would create a view as Steve suggests - but instead of putting a constant of 1 into the second column I would suggest putting either #DocChildren (for immediate responses) or #DocDescendants (for all responses and responses to responses).
If I understand your logic then all the ones returning 0 (zero) are child documents and those returning 1 or higher would be parent documents. Of course you could also use an item on the document in your view formula - if it only exists on the parent doc (or its value can tell that it is a parent doc)
View selection formulas act on only one document at a time. They cannot perform lookups. They have no way to compare two documents. There is therefore no possible way for a view to identify duplicates.
A view can, as per the other answers, categorize documents based on common values. If there is a single field that is supposed to be unique across all documents, you can categorize on that field. That will give you a visualization of the duplicates, but it won't filter them in or out.
The only way for a view to filter duplicates - either to show only duplicates, or to exlude duplicates - would be if you run an agent that reads all documents, looks for those that are duplicates, and marks them with a special field value - e.g., IsDuplicate = 1. Once you do that, you can create a view that selects all documents with IsDuplicated = 1, or a view that excludes IsDuplicated = 1.

Add up values from matching fields in a linked Sharepoint list

I have 2 lists, say, Fruits & Orders.
Orders has a number field FruitID that links to the ID field of Fruits.
Orders also has a number field OrderValue which stores the value of the specific order.
I want to find out the total sale for a particular fruit. I am doing this calculation in a workflow for the specific fruit. Is there an easy way (read 'no coding')?
See the list of standard workflow actions here:
http://office.microsoft.com/en-us/sharepoint-designer-help/workflow-actions-in-sharepoint-designer-2010-a-quick-reference-guide-HA010376961.aspx
There is no select, or looping functionality.
I suggest writing a custom workflow activity, sand boxing should work
http://www.wictorwilen.se/Post/Sandboxed-workflow-activities-in-SharePoint-2010.aspx

Display column from one Sharepoint list into another list

I have one Sharepoint list that contains training courses and duration (in hours). I have another list where users can enter the training they have and plan to take (using a Lookup column connected to the first list)
Is there a way I can bring over that Hours column to display on the second list? I only have access to the vanilla web parts and SPD, and I am not allowed to add third-party stuff (solutions/web parts) on the SP servers.
I just need that Hours column to appear in the list itself without users needing to click the lookup field (course title)
If you have multiple column field type and you use that as lookup field. You can get two column values in one field. It will show up as two different columns on list but you will need render templates for input forms. Check this out for basic idea
http://msdn.microsoft.com/en-us/magazine/dd727508.aspx#id0450138
Create a field type for course list
Create render template for MCV and extend SPFieldMultiColumnValue
Make that field as Lookup Column
You have to check if you can do second step using SPD only. Also another way to do it is using Multiple column lookup field
HTH

Resources