1. Help Center
2. Reference
3. Calculated Properties

# Combining multiple properties into one

## Calculated Properties can combine, select and gate other properties

A CP can combine multiple properties into one with a formula and/or logical operation.

### Unifying device schemas

If you have two types of device, and one type reports "temp" and the other type reports "temperature", then you could define a universal property (to use in KPIs etc.) which will be correct for both types of device:

temperature_unified:

`temp ? temp : temperature`

### Calculations on multiple properties

You can also combine multiple properties using a formula: if your device reports air temperature and device temperature, you can create a property which is the difference between these values.

temp_difference:

`air_temp - device_temp`

Some qualities are inherently multi-dimensional, which makes them hard to analyse as a single number. For example, comfort is determined by both temperature and humidity, so if your sensor reports both values then you can combine them into a single "comfort" index which returns 1 at the perfect combination, and smaller numbers the further away you get (with a slight tendency for warmer temperature to be comfortable when humidity is low)  e.g.:

comfort_index:

`1 / (1 + abs(temperature_C - 26 + relative_humidity / 50) * 0.2)`

You could then use a KPI to measure the average comfort level over time in each room, or the minimum comfort level etc.

Likewise, aspergillus mould has an optimum temperature at which it grows on surfaces in buildings (a relative humidity of about 99 and a temperature of 28 C are what it likes best), so here's a formula which returns 1 at the conditions the mould likes best, and then falls off as temperature or humidity move away from its optimum.

mould propensity:

`max(0,1 - abs(99-relative_humidity)/9 - abs(28-temperature_C)/15)`

You could then use a KPI to integrate the amount of mould-growing potential that each room has accumulated over say the past week.

### Selecting from multiple properties

You can use CPs to make one property which follows the value of two or more other properties, dependent on some criterion, and for this we use the ternary "?" if/then/else operator. For example, if our device has a knob to select whether it measures inside or outside temperature, we could say:

display_temp:

`selector == "inside" ? inside_temp  : outside_temp`

Or perhaps you have some US devices reporting temperature in Farenheit on one property, and some European devices reporting temperature in Centigrade on another property? A CP can unify these into a single universal temperature property:

temp_C:

`made_in_usa ? (tempF - 32) * 5.0 / 9.0 : tempC`

You can also use the "?" operator to ‘gate’ or mute a property, based on its own state or that of another property. For example, buildings which have solar panels experience electricity-flow both in (+ve) and out of them (-ve), and summing such a value in a KPI will correctly give you the overall net figure. But if you wanted to gather stats on just the exported amount, you could gate the value thus:

energy_exported:

`energy < 0 ? -energy : 0`

Sometimes you may have multiple properties describing the state of your machine, for example multiple error properties each of which can be true or false at any moment in time. With CPs you can combine these into a single property (based on e.g. their priority). Then they just occupy one column in a list, and you can GROUP BY the current worst error:

worst_current_error:

`polonium_leak ? "Polonium leak" : loose_nut ? "Loose nut" : null`