Click here to Skip to main content
15,892,927 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a column in sharepoint list with repititive values. I want to get the count of each distinct value and display it as a report in the descending order of count.
Posted

If you are using .Net 3.0 (or higher), use LINQ.

There are some good count samples here[^]. Check if any of them suits you (the count by group one specifically).

If you post some code here, members would be able to provide more details on how you should go about your solution.
 
Share this answer
 
v2
If you're not using LINQ, you could just use a dictionary to do such.

Ex.

Dictionary<string, int> dict = new Dictionary<string, int>();
int intCount;
 
foreach (string strValue in values)
{
  if (dict.TryGetValue(strValue, out intCount))
    dict[strValue] = ++intCount;
  else
    dict[strValue] = 1;
}


Something like that...after you're done, the dictionary will have all the unique values as keys and the counts of how many for each in the value portion.
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900