Creating and Editing Variables

Overview

Variables are the building blocks of your models. If you're a spreadsheet user, you can think of them a bit like spreadsheet cells. If you're a programmer, you can think of them as, well, variables.

You can define a variable using a formula. Formulas let you work with numbers, ranges, and other variables.

Creating a Variable

To create a variable:

  1. Click New Variable at the end of a section.

    Creating a new variable
  2. The following drop-down menu is displayed:

    Dropdown menu for a new variable
  3. Do one of the following:
    • Create a new variable: If you select this option, enter the name of the new variable in the input field.
    • Create from data: Creates a new variable from a data item. If you select this option, you can first select the desired data source and then the desired variable. For more information on this topic, see Linking Variables to Integrated Data.
    • Import variable: Reference a variable from a different model. If you select this option, you can first select the desired model and then the desired variable.
  4. If you have defined a new variable, you can then specify its format type by clicking on the  icon or the icon to the left of the variable name:

    Choosing a data type for a variable
Main Format Types

There are five main format types for variables: NumberCurrencyDatePercent, and Boolean


Format type

Description


Number 

For quantities that aren't percentages or currencies.


Date

The number will be formatted as a date. You can enter the date as date(yyyy,mm,dd) or as date(yyyy,mm).


Currency $

Choose a specific currency (e.g. USD), or select Custom if the currency is not listed (e.g. cryptocurrencies). The currency symbol for common currencies is pre-set from the currency you select (e.g. $ for USD), but you can manually change the prefix/suffix.

To learn more about Currency and how xP&A handles FX conversion, see Currency & FX Conversion.


Percent %

This expects the variable's value to be a decimal.

Example: 0.5 will be displayed as 50%. You can also enter directly as "50%".


Boolean

A variable that can be True or False (1 or 0), displayed as a checkbox/toggle.


Using Advanced Formatting Options

In addition to the standard formats, advanced formats can also be assigned to a variable. Proceed as follows to use the advanced formats:

  1. Click to open the context menu.
  2. Click Format.
    .
    Context menu 'Format'
  3. The context menu is displayed as follows:

    Advanced format options
  4. Choose the desired option (see Advanced formatting options).
Advanced Formatting Options

The following advanced formatting options are available in the Format context menu:


Option

Description


Human-readable

1,000 -> 1k, 1,000,000 -> 1m, etc. Human readable is automatically on.


Comma separators

Comma separators, i.e. 1000 -> 1,000, 10000 -> 10,000, etc. Comma separators are automatically on.


Zero as

Displays cells with 0 values as -, making it easy to spot cells that have non-zero numbers.


Negatives

Accounting negatives i.e. ($100,000) not -$100,000 Red negatives i.e. -$100,000 or both ($100,000)


Precision

Automatic, or specify the number of decimal places or significant figures.


Magnitude

Automatic (as entered), or specify the 'unit' (thousand, lakh, million, crore, billion, trillion) you want to display the value in. For example, if you entered 100 but format the display as 'thousand', this will be 0.1k.


Relative time

Activate to use relative time for the variable. For more information, see Relative Time for Variables.


Lower is better

Activate if in comparisons values of the variable shall be displayed in green if they are lower than the values they are compared with.


Adding a Custom Prefix and/or Suffix (Custom Units) to a Variable

You can set custom unit format for your variables, and set whether that unit is displayed before or after the number (prefix vs. suffix).

To add a prefix and/or a suffix:

 

  1. Click to open the context menu.
  2. If necessary, use the dropdown menu to switch to prefix or suffix.
    Add suffix and/or prefix to a variable
  3. Enter the desired prefix or suffix in the input field.

This gives you ultimate flexibility to visually distinguish the units of variables in your models (e.g. currencies, earnings multiples, ratios, time units etc). Note that custom units are purely visual and do not affect calculations whatsoever.

Shows example of prfixes and suffixes in the right column Examples of prefixes and suffixes
Types of Variables

There are three variable types used in formulas in xP&A, and they are distinguished by their colour.

Blue variables are variables that are coming from the existing model.

Shows a variable that is coming from the existing model colored blue Variable that is coming from the existing model

Green variables are variables that are coming from a linked model. If you hover over the variable you can see which model it is coming from.

Shows a variable that is coming from a linked model colored green Variable that is coming from a linked model

Purple variables are Causal's special helper variables, e.g. today, none, date / timestep, cohort.

Shows a helper variable colored purple Helper variable in XP&A