Scripting > Expressions > Hierarchical expressions > up-lev (.() operator
 
up-lev (.() operator
You use the up-lev operator in combination with an aggregate function when you want to include data from a lower level in an expression at a parent level.
Syntax
Aggregate(ChildLevel.(Expression))
Parameters
Aggregate
One of the aggregation functions supported by the UNICOM Intelligence Data Model.
ChildLevel
The name of the child level from which you want to up-lev the data.
Expression
The expression to be up-leved.
Aggregate functions
AVG(expr)
Returns the average of the values defined in the expression. This function can be used with numeric data only.
BASE(expr)
Returns the total number of cases included in the expression. Generally, the base includes every case for which the value is not NULL.
COUNT(expr)
Returns a count of the cases selected by the expression.
SUM(expr)
When used with numeric data, returns the sum of the values. When used with categorical data, it returns the union of the categorical values.
MIN(expr)
Returns the lowest value defined in the expression.
MAX(expr)
Returns the highest value defined in the expression.
STDEV(expr)
Returns the standard deviation of the values defined in the expression. This function can be used with numeric data only. The standard deviation is a measure of dispersion around the mean. In a normal distribution, 68% of cases fall within one standard deviation of the mean and 95% of cases fall within 2 standard deviations. For example, if the mean age is 45 with a standard deviation of 10, then 95% of the cases would be between 25 and 65 in a normal distribution.
Up-leving one level
In the following top-level expression the up-lev syntax has been used to up-lev the data in the Person-level Gender variable to the top level:
Sum(Person.(Gender = {male}))
This expression returns the number of males in the household.
The next expression is at the Person level and includes the up-lev syntax to promote the data in the Trip-level DaysAway variable to the Person level:
Gender = {Female} And Age > 16 And Sum(Trip.(DaysAway)) > 20
This expression selects women who took overseas trips that lasted a total of more than 20 days.
The next expression is at the Vehicle level and includes the up-lev syntax to promote the data in the Rating grid to the Vehicle level:
Sum(Rating.(Column * {Very_good}))
This expression selects vehicles for which the respondent selected the Very good category in response to at least one iteration of the Vehicle-level Rating grid.
Up-leving two levels
You can use the up-lev syntax multiple times to up-lev by more than one level. For example, the following expression is at the top (HDATA) level and the data in the Trip-level DaysAway variable has been up-leved twice to the top level.
Sum(Person.(Sum(Trip.(DaysAway > 20))))
This expression selects households in which at least one person took at least one overseas trip that lasted more than 20 days. If you want to select households in which at least one person took overseas trips that altogether lasted more than 20 days, you would need to move the comparison operator outside the innermost parentheses:
Sum(Person.(Sum(Trip.(DaysAway)) > 20))
See
Hierarchical expressions