Reputation: 21
How can I count the instances that match the item in one list from another?
Please see scenario for example.
I have 2 SharePoint lists.
List A is a list where managers record scores for their associate audits.
Associate Score
---------- ------
Associate 1 100
Associate 2 100
Associate 1 90
Associate 1 50
Associate 2 0
Associate 3 80
And List A grows on and on as new reviews are added.
List B is just a staffing list and only holds one instance of the associates name.
I want List B to count the number of times it appears in List A, so when a new item is added to list A, it automatically counts it in list B. For example:
List B
Associate Count
---------- -----
Associate1 3
Associate2 2
Associate3 1
Something similar to a count for a query in Access or countif in excel, just for further clarification. Any suggestions?
Also, the Associate Field is a Group/People Type so it matches their userId, if that matters any. I would prefer to keep it that way, but I am open to suggestions. I am also using SharePoint 2007.
Upvotes: 2
Views: 16251
Reputation: 348
You could also create a workflow in SharePoint designer that would add count to list B.
For example you have in List B that has Associate1. When you create an item in list A, do a workflow that would look for Associate1 in list B, then add +1 to the counter of list B on that Associate.
Upvotes: 0
Reputation: 31
If your list A is using a lookup column to list B for the associate names, this should be pretty simple.
Simple go to list B, and add a new column that is a lookup to list A. When you drop down the fields to choose from, you should see Associate(count).
This will count the number of times each associate name is used in List A, and will display the count exactly how you want.
Cheers!
Upvotes: 3
Reputation: 1697
Instead of creating List B, just create another VIEW on List A. You will have 2 views of List A (AllItems.aspx and YourName.aspx). The second view will group by the Associate field and the count will update itself when items are added to List A.
Otherwise, if you really need another list, List B, you will have to replicate the insert in List A with an insert in List B (using event receivers or workflows) and then create the same type of view on List B as above.
Why have 2 lists? Have 2+ views!
Upvotes: 0