In Harmoni, measures represent continuous variables and contain numerical values.

Constructions are used to create new items or variable types in a project. You can create new continuous variables using items that already exist in the project, or with user-entered values.

**Measures**

To create a measure, you first need to select the desired position in the project tree. From here choose * new measure* under

*and then define the expression using the expression editor.*

**construct**from the**design menu Learn more about the design menu.**- You can create new measures from an existing measure, or weight, values, or by entering values explicitly into the definition.
- Measures contain a single value for each respondent.
- Records to be excluded from the measure’s count need to be assigned a NULL value.

**In this article**

**1. Conditions and Functions**

**a) If statements**

If statements are used to populate a new measure or weight with a different value depending on specific conditions.

**If statement syntax**

- The syntax for the if statement is:

*if (Logic_Test, Value_if_True, Value_if_False)*

- The syntax for a nested if statement is:

* if (Logic_Test, Value_if_True, if (Logic_Test, Value_if_True, Value_if_False))*

## Example

Let's assume you want to calculate the NPS based on the "*Likely to recommend*" question. For this, you need to assign the appropriate -100, 0, and 100 values to each respondent. The records to be excluded from the measure’s count need to be assigned a NULL value.

The syntax in this case would be:

if(Recommend.(9 or 10) ,100,if(Recommend.(7 or 8), 0,if(Recommend.(0,1,2,3,4,5,6),-100,null)))

Where:

- Logic Test - Likely to recommend
- Value if true - Factor to be applied (-100,0 or 100)
- Value if false - Null.

Now, let's assume we want to create a separate NPS for only Females. Your logic test needs to consider this condition: "*Likely to recommend*" question and Gender.

if(Recommend.(9 or 10) and Gender.Female, 100,if(Recommend.(7 or 8) and Gender.Female, 0,if(Recommend.(0,1,2,3,4,5,6) and Gender.Female,-100,null)))

- Logic Test - Likely to recommend and Gender
- Value if true - Factor to be applied (-100,0 or 100)
- Value if false - Null.

**b) Count responses**

The count function is used to **define a new element or a new measure **by counting the number of responses given to the items listed in a comma-separated list. The count function creates a **numeric value** from an existing axis, element or measure. Learn more about the Count function

**Count function syntax for measures**

**a) Counting all responses in a standard axis.**

With this syntax, the values count returns are the number of elements each respondent responded to. Note, only multiple-response variables will ever give a count greater than 1.

- Measure:
*count (AxisName1)*

**b) Count function with Boolean logic can be used to count whether a respondent mentioned at least one response to a specific set of items.**

**Using count ( _ or _ or _ )**

With this syntax, the values count returns are 0 and 1. The maximum count the expression returns is 1.

- Measure:
*count (AxisName1.(ElementName1 or ElementName2 or Element 3))*

**Using count ( _ , _ , _ )**

With this syntax, you can sum together counts from a specific set of items. It evaluates the number of items a respondent has answered and adds the count for each. The maximum count the expression returns is the max number of possible responses.

- Measure:
*count (AxisName1.ElementName1*__,__AxisName1.ElementName2 , AxisName1.ElementName3)

**Examples**

Let's assume you want to find out the number of activities during a trip, excluding the element "*None of these". * In this case, the best syntax to use is count** ( _ , _ , _ ). **This will just take into account the elements you want to include in the calculation.

**c) Calculations**

Measures can also be defined using calculations, i.e.

- Addition using +
- Subtraction using -
- Multiplication using *
- Division using /

**Example**

Let's assume you want to create an "*Other Costs"* measure containing the amount spent that wasn’t on airfares or packages, i.e. the amount left after subtracting airfares and packages from total spend.

**d) Aggregation Types (Multi-level only)**

Four aggregate types are available: Sum, Avg, Min and Max. When creating an aggregate measure or weight, for example, at the parent level, the calculations are as follows:

**Sum**– all records at the child level are added together to become the aggregate result at the parent level.-
**Avg**– all records at the child level are added together and divided by the number of records to become the aggregate result at the parent level. -
**Min**– just the lowest record at the child level is used as the aggregate result at the parent level. -
**Max**– just the highest record at the child level is used as the aggregate result at the parent level.

**Example**

Let's create an "Average Occasions*" *measure at the parent level using the occasion data from the child level.

- Add a new measure at the parent level and define it.
- Select the aggregate type you need.
- Save or apply the expression.

**Where to from here?**

Learn more about different construction types.