# How to write Calculated Information

## Definition

Calculated information is information atfinity deduces from data available elsewhere in a case. A new value is created, based on the condition you define.

Calculated information can never be edited by a user. It is recalculated each time something changes in the information fields it uses as source.

## Options

When configuring a piece of information, you are asked whether it is calculated information or not. If you set this to Yes, a field with two extra options appears:

 Option Description Condition Using RuLa, write the formula that will calculate the value of the information as a single expression. Display calculated information? Yes: this information will be displayed in the case.No: the information is still calculated and can be used in the process, but will not be displayed in the case manager.

## Writing a Condition

A calculated information consists only of an expression that defines the output of the calculated information. It has to follow the output type of the information. Inside the expression you can access information of the instance the calculated information is connected to with `self`.

## Examples

### Full name of a person (Text)

A person's name can be split over three different information fields:

• `first_name`

• `middle_name`

• `last_name`

However, you also want one field on the document to contain the full name. To get this, attach this condition to the calculated information field `full_name`:

`CONCAT(self.first_name, " ", self.middle_name, " ", self.last_name)`

This takes the data of the three fields listed above, inserts a space between each value, and combines them as a single new value of the field `full_name`.

Whenever the information in any or all of the three individual fields is changed, the information in the field `full_name` will be recalculated accordingly.

â€‹

### More checks necessary? (Boolean yes/no)

Based upon information on a person's wealth, a bank wants to calculate whether or not additional checks are required.

The condition that calculates whether the qualification 'High or Suspect Wealth' is relevant could be:

`self.total_wealth > 2000000orself.source_of_wealth contains other`

Line 1 and 3 are expressions, that take in values from the fields `p.total_wealth` and `self.source_of_wealth`. The operator `or` that separates the expressions, implies that only one of them has to be 'true' for the entire condition to evaluate to 'true'.

If the person in the case holds a total wealth of over two million, according to the information given in the field `self.total _wealth`, or if the field `self.source_of_wealth` contains 'other', next to for example 'employment' and 'investments', the calculated information field 'High or Suspect Wealth' evaluates as 'true'.

â€‹

Average revenue (Number)

There can be good reasons to want to calculate the expected revenue of a corporate client for 2021, based on the averages of that company's revenue over the years 2018, 2019, and 2020. For example to decide on a loan the company is applying for.

The revenue over the past three years is collected in separate information fields, for example:

• `self.revenue_2018`

• `self.revenue_2019`

• `self.revenue_2020`

You create a new information piece, `self.expected_revenue`, that holds the expected revenue for the following year by calculating the average of the values from the three fields listed above. You can get that by writing the following formula in the condition field for `self.expected_revenue`:

`AVG(self.revenue_2018, self.revenue_2019, self.revenue_2020)`

In the configuration of the information `self.expected_revenue`, set a number variant as the output type.

â€‹

### Service level (Case when... else... end)

A bank could determine the number or level of services offered to a client, based on that client's annual income. The bank has four service levels on offer: bronze, silver, gold, and platinum. What level a client falls into, is calculated from the annual income. In other words:

the information `service_level` is calculated from the information `annual_income`. Up to an income of 150,000 the client is offered the bronze service level. With an income between 150,000 and 500,000 the silver level is offered, gold for incomes between 500,000 and 1,000,000 and platinum for incomes of over a million.

The condition field for information service_level should read:

`case    when self.annual_income <= 150000 then bronze    when self.annual_income <= 500000 then silver    when self.annual_income <= 1000000 then gold    else platinumend`

â€‹