---
title: "Variable Modifiers"
description: "When you reference a variable in a formula, there are two key ways to modify it - using Categories (if applicable), and Time."
source_url: https://support.lucanet.cloud/en/documentation/xp-a---extended-planning-and-analysis/modeling-your-data/create-andedit-formulas/variable-modifiers
language: en
last_updated: 2023-08-16
---
# Variable Modifiers in Formulas

## Overview

When you reference a variable in a formula, there are two key ways to modify it - using **Dimensions**(if applicable), and **Time**.

## Time Modifiers

Time modifiers allow you to reference various different time instances of a variable.

Time Modifier

## Types of Time Modifiers

The following types of time modifiers are available:

### Relative

**This 'month'**: returns the current value of that variable

**Previous 'month'**: returns the previous value of that variable, relative to the time step in which the formula is being applied.

**Example**: In June, **Customers\[previous\]** corresponds to the value of **Customers** in May.

{% info-box %}
By default, when you reference another variable, xP&A will return the current value of that variable. When you reference the variable itself, xP&A will return the previous value of that variable.
{% /info-box %}

**Look-back** and **look-forward**: returns the value of that variable x days/weeks/months/years in the past or future, from "t" (the current time step).

**Example**: if you want xP&A to return the value 12 months ago, your time modifier would be **t-12**. Conversely, if you wanted to return the value three months in the future, your time modifier would be **t+3**.

Looking back 6 month ago

{% info-box %}
In a look-back or look-forward, you may reference dates that are _before_ the start, or _after_ the end of a model's date range. These cells will evaluate to the empty value of the variable (ie., either 0, or the **none** value).
{% /info-box %}

### Fixed

### **Final**: returns the value of the final timestep of the model for that variable. Note that if you extend your [model time settings](https://support.lucanet.cloud/en/documentation/xp-a---extended-planning-and-analysis/modeling-your-data/working-with-time.md), any variables referencing the final time step will auto-update.

**Absolute**: returns the value of a single, particular timestep for that variable. e.g. 1 refers to the 2nd timestep of the model, 0 refers to the 1st timestep of the model etc. You can also just type in **date(YYYY,MM)** instead of the timestep index number.

### Spans

Spans are a sequence of time steps, e.g. past six months in a monthly model would be **t-6:t-1**.

{% info-box %}
Spans always need to be aggregated, e.g. wrapped in a **sum** or **avg** function.
{% /info-box %}

**All**: returns the sum of all time steps for a variable.

Using 'All' in a formula

**Span with a custom start/end-point**

- E.g. first 6 days/weeks/months/years of your model: 0:5 (absolute)

Using a span ('first 6 months') in a formula

- Past three days/weeks/months/years (relative, useful for rolling averages)

Using 'last 3 months' in a formula

## Dimension Modifiers

Dimension modifiers allow you to slice and dice referenced variables within formulas, using the related dimensions and dimension items.

You can use the following dimension modifiers to modify referenced variables within formulas:

### Grouping by Linked Dimensions

Once you have [linked dimensions together](https://support.lucanet.cloud/en/documentation/xp-a---extended-planning-and-analysis/modeling-your-data/using-dimensions/create-edit-dimensions.md), you can then easily slice variables along different dimensions.

**Example**: We have an **Employee** dimension, which is linked to a **Team** dimension. By default, we've worked out **Salaries** by **Employee**, and now we're interested in seeing **Salaries** by **Team**.

Click on the **Dimension** icon in the referenced variable in the formula, and then select the desired dimension and click **Group by**.

Using 'Group by'

{% info-box %}
If you want to "Group by" **multiple dimensions** at one time just hold down **Shift** and click each of the dimensions you want to select. e.g. if you want to group by **Team** and then **Role**. This displays as multiple layers of nesting.
{% /info-box %}

### Filtering by Dimension Items

Sometimes you'll want to select a single item from a dimension and use it in a formula.

Click the **Dimension** icon in the referenced variable in the formula, select the desired dimension, and then click the individual item you want to filter by.

**Example**: If you want to do a calculation only based on the **Engineering** Team's salaries, you would select **Engineering** under **Department**.

Filtering by category item

{% info-box %}
If you want to filter for multiple dimension items, just hold down **Shift** and click each of the dimension items you want to select.
{% /info-box %}

### Aggregating Away a Dimension

Sometimes you might want to aggregate away a dimension, if you no longer care to see that level of granularity.

**Example**: If you have filtered **Salary** by **Employee** for just the **Engineering** team, but no longer care to see the **Employee** breakdown, you can aggregate the **Employee** dimension.

Use the two commands **Aggregate** **(Sums across dimension)** and **All (Keep dimension intact)** to remove or re-add the breakdown of a dimension. To do this, click on the variable in the top bar:

Aggregating away a category

### Other Ways of Using Dimensions

There are a few other ways that you can use or manipulate dimensions and dimension items within variables and formulas, that are not variable modifiers in formulas.

### Aggregating at the Variable Level

Sometimes you might want to change how a variable aggregates its dimension items. xP&A's default is to sum the dimension items, but see [Dimension aggregation](https://support.lucanet.cloud/en/documentation/xp-a---extended-planning-and-analysis/modeling-your-data/using-dimensions/aggregating-dimensions.md) for more options.

### Dimension Items in Formulas

[You can also reference dimension items within formulas](https://support.lucanet.cloud/en/documentation/xp-a---extended-planning-and-analysis/modeling-your-data/using-dimensions/dimensions-variables-and-formulas.md).
