Group and Count by Sub List Values

Hi All,

I have scratched my head over this for a while now and bet there is a simple answer to the problem! I need to group items in a sub list based on values. For example, I may have one list with the following {“1”,“2”,“2”,“2”,“3”,“3”,“4”} and a second list with {“2”,“2”,“2”,“3”,“3”,“1”,“1”}. So index 1 and 2 match and there are 2 items. Index 4 matches and there are 1 item.

Hope this makes sense to everyone. I have fried my brain!

Lawrence

I’m not sure I understand how you want the result to look like, but here is a guess:

@Lawrence_Hooker Not sure I understand your intent either. But here is my interpretation…
I’m going to assume that you want to pick subsequent pairs in a list, group them with corresponding pairs in another list and then get the unique items.

Hi Einar,

Sorry I didn’t explain myself very well. I need to find how many pairs of matching numbers are in a list. So I may have the numbers 5 and 3 and then another instance of 5 and 3 in the same list. I would like to be able to group and count these matching pairs.

I guess another way of explaining would be to imagine a few rectangles and I want to group the same rectangles by length and width so I have a list and count of the same size rectangles.

@Lawrence_Hooker Okay! I think that was clear. Something like this then?

Or maybe something like this …
GroupBySubList.dyn (5.9 KB)

2 Likes

If you prefer Vikrams solution, you can get the count of pairs in each group and the unique groups with Count and List.FirstItem.

GroupBySubListWithCount.dyn (6.7 KB)

Spot on Vikram, Thats what I was looking for. I will give that a try. Thank you.

You guys are very good, thanks for your ideas.