Scripting > Expressions > Hierarchical expressions > Working with parallel levels
 
Working with parallel levels
In all of the examples we have considered so far in this topic, we have used levels that have a direct parent-child relationship. However, some data sets contain levels that are not related to each other. For example, if you scroll back to the diagram that shows the levels structure of the Household sample, you will see that the Person and Vehicle levels are parallel to each other (on different branches of the tree). This means that the data in the two levels is not directly related to each other. However, sometimes you may want to include data from parallel levels in an expression. For example, you may want to select men who live in households that have a motorbike. To do this, use the data in the Vehicle level in your Person-level expression.
When you include data from a parallel level in an expression, you must up-lev the data to the first common ancestor level and then down-lev the data to the level of the expression. In the Household sample, the only level that is an ancestor of both the Person and Vehicle levels is the top (HDATA) level. The following expression up-levs the Vehicle-level data to the top level and down-levs it to the Person level:
^.Sum(Vehicle.(VehicleType = {Motorbike})) > 0 And Gender = {Male}
This expression selects men and boys who live in a household that has one or more motorbike.
See
Hierarchical expressions