# Return a unique value between 0001-1000 if 2 conditions are met

Hello! I am rather new to Dynamo and am in the midst of a school project. I am trying to do the following:
Assign a unique 4 digit code to given elements if the combination of 2 parameters match, not one or the other, but both. Created something out of thin air and it seems to almost work but I am missing something that i cannot identify.

Welcome!

Youâ€™ve got a couple good parts, we just need to piece them together properly and fill in the gaps.

There have been a couple discussions already today about searching/matching strings with multiple requirements. Iâ€™d suggest taking a look at those, but the main idea is that you want to check both conditions individually and then check a third time to see which elements specifically pass both conditions.

Iâ€™d filter your elements first, before creating a unique value. That way you have exactly the number of elements youâ€™re writing to and donâ€™t have to deal with another conditional statement. For the â€śrandomâ€ť part Iâ€™d suggest a `Math.RandomList` node, specifically one that allows you to set the `amount` of random values to generate. This does not actually ensure that all the values generated will be unique however. This can be more or less of a problem depending on how many values youâ€™re creating, but we can solve that problem when we get to it.

EDIT: The thing I donâ€™t understand is why youâ€™re comparing the `FamilyInstance` Level with the `Space` Name. Those are two different elements with no relation, so you canâ€™t compare them together. Are you wanting to get the `Space` of the `FamilyInstance` and compare that way?

2 Likes

Hello, and thanks for the answer

So the reason Iâ€™m comparing the two is less of a comparison, but more of a way to identify and assign the code to the elements Iâ€™m targeting. And the reason Iâ€™ve used a Space for this is because the model Iâ€™m working with is split into 4 parts (A-D), and I did this with Spaces, though Iâ€™m not sure if this is the most optimal way. I will try out what you suggested though, and see where it takes me

My point is that thereâ€™s nothing that ties the spaces to the elements. So you have values for the element and values for the space but then use all of those values when writing back to the element. The spaces have nothing to do with the elements so you canâ€™t use them in the analysis of the elements.

Ah, I didnâ€™t realize that. Well that explains why I couldnâ€™t figure out a solution after all this time. How do you suggest I separate the buildings in order to build that connection I was looking for if not with Spaces?

As a temporary but subpar solution, I had to opt to using the All Elements in Active View node and actively filter out elements in schedules as I went on with the codes

I think you need to get the Spaces from the Elements. That way there is a one-to-one connection between the element and the space youâ€™re checking.