|
-
Jul 7th, 2022, 02:23 PM
#1
[RESOLVED] Count of unique values in a collection
I have a sorted collection of 4-digit numbers and many of the numbers are duplicated. I'm looking for a quick way to get a count of each unique value. For example if 1234 occurs 3 times in the collection and 2468 occurs 5 times in the collection I'd like to wind up with an array that contains 1234|3 and 2468|5.
Could I use a Dictionary by itself without having to use (and sort) a collection and a separate array?
-
Jul 7th, 2022, 02:29 PM
#2
Re: Count of unique values in a collection
Should be able to... check the dictionary to see if the key exists, if it does, +1 the value, if not, add it and set the count to 1.
There may even be a way to use linq to aggregate the data for you and return an array.
-tg
-
Jul 7th, 2022, 02:33 PM
#3
Re: Count of unique values in a collection
Should be able to... check the dictionary to see if the key exists, if it does, +1 the value, if not, add it and set the count to 1.
Can you supply sample code? I haven't had any experience with dictionaries.
-
Jul 7th, 2022, 03:33 PM
#4
Re: Count of unique values in a collection
Found an easy solution using a worksheet, =Unique and =CountA. No collection or Dictionary needed.
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|