Filtering nested list, based on their values

listfilter
dynamo
#1

Hi everyone,

I’m trying to figure something out, in which I do not know how to accomplish currently.
I’m quite new to the Dynamo workflow, but I’ve managed to get a lot of work done already (So far I love it). The only thing that is bothering me is the following challenge:

I’ve got a list which contains 3 nested lists with 3 nested list in it.

Combined with a filter based on the first value of the nested list (64, 62 or 61 in this example) I want to have an output that simply “cuts” the nested list based on the filter but with an output related to the existing list (64, 8) (62, 6) (61, 5). This means the following: Filtering on number 64, is gives a true value which initiates an action to give the complete list of 64 and 8.

In this way, I can manually add the second number (index 1) to a list.join specified for the 64, 62 or 61 code. The 6x… numbers are related to the NLSfB codex.

Please, can anyone help me?

Thanks in advance,

Marcel

0 Likes

#2

List.GroupByKey will do the trick, on either just the sublist (as I show), or the original lists if you want to keep them together.

0 Likes

#3

hm… not exactly what I meant or I just don’t understand.

With the list.countoccurences I get a list containing, as an output, the “Unique elements” and “count”. The index value of the list corresponds to each other, only seperating the list into unique components based on the key values is something I don’t understand.

In the example you’ve made, you’ve managed to make a list which contains more then 1 “64” data types.

I Hope the picture gives some more context.
From the example you’ve provided me I already got (the List.last item and List.Firstitem are derived from the List.CountOccurences.

Greetings,

Marcel

0 Likes

#4

Can you upload everything needed to get to your start point? I’ll try and have a look tonight.

0 Likes

#5

well… the model is 75 mb. I don’t know If we can do this through teamviewer?

0 Likes

#6

if the original list is fed into the group by key the resulting output should be sorted. Or the Ampersand package has a great list sort by key node

0 Likes

#7

This is the total script btw.

0 Likes

#8

Filter, Dynamo.dyn (12.3 KB)

Hereby the script.
The top part is the current situation.
The lower part is the situation I want to create.
The only part I don’t know is how to filter based on the nested value within the list…

If someone can help, thanks in advance.

Greetings.

Marcel Reitsema

0 Likes

#9

What you are asking for is List@Levels I believe. The Dynamo Primer has a small section explaining it if you want to read: https://primer.dynamobim.org/en/06_Designing-with-Lists/6-3_lists-of-lists.html about half way down the page or search for List@Level.

Although maybe I am misunderstanding this but I don’t think it is really required here. Here are a few different ways to get what you are looking for based on the picture above:
(Note that only the last group returns the single item, the rest returns a list that you would need to change to the single item. The first group is just an example of what list level does)

1 Like

#10

Thank you so much.

Since I realized I used a list.create (instead of list.join) I stumbled upon the fact that my list contained a count value (double or number) and a string value list (is there a better way of checking the data types?)

Based on a range of numbers (31,42,43,45,54,57,61,62,63,64,65) I needed to check what the total amount of families where that were intersecting the first element with a filter based on a provided NLSfB number.

With this I can dynamically filter all the families and count the occurences.

Lesson learned and again! thank you so much.

Greetings,

Marcel

1 Like