# Lookups

## Overview

Sometimes you will need to lookup a [**Variable**](/variables/variable-basics.md)'s value based on another Variable's value.

> For instance, let's say we have a Model with four cost categories. For each cost category we want to apply one of two inflation types, RPI or CPI (Retail and Consumer Price Index respectively). We want to be able to dynamically choose between the two options, and for the cost item to use the correct inflation value automatically.

This is achieved using a Lookup reference - we explain how you can achieve this below.

{% hint style="info" %}
This is the kind of operation you typically perform in Excel with an INDEX-MATCH formula, or an [**XLOOKUP**](https://support.microsoft.com/en-us/office/xlookup-function-b7fd680e-6d10-43e6-84f9-88eae8bf5929#:~:text=The%20XLOOKUP%20function%20searches%20a,Argument)
{% endhint %}

## Lookup reference example

<figure><img src="/files/6IsvXgzurphn3Vzo1az5" alt=""><figcaption><p>Example of a Lookup reference</p></figcaption></figure>

This above example illustrates the scenario described in the [**Overview**](#overview). `Recurring cost inflation` pulls its values from `Inflation by type` according to the selected value in `Recurring cost inflation types`.

## Creating the Lookup reference

To create a Lookup reference, perform the following steps, as illustrated in the screenshots below:

1. In the [**Calculation step**](/calculations/the-calculation-page.md), add a Variable reference to the target Variable <mark style="color:green;">**(1)**</mark> (in the above example `Inflation by type`) using [**any method**](/calculations/calculation-parts/variable-references.md#overview) - by default, the reference will be a Summary of the target Variable, because the target has different [**Dimensions**](/dimensions/introduction-to-dimensions.md), so an `Auto` reference is not possible.
2. Edit the Variable Reference Calculation Part that has been added <mark style="color:green;">**(2)**</mark>
3. In the **Reference type** page of the dialog, select a LOOKUP reference <mark style="color:green;">**(3)**</mark>
4. This will display a new step, in which you can select a Variable with which to perform the LOOKUP <mark style="color:green;">**(4)**</mark>. This Variable will need to have the same Dimensions as the Variable in which you are performing the Calculation. By default, this list will be filtered to Variables with the correct Dimensions.

{% hint style="info" %}
Create the Lookup Variable by using the [**Validation data type**](/variables/variable-basics/variable-setup.md#validation-dimension) - in this case using `Inflation type` as the Validation Dimension.
{% endhint %}

<figure><img src="/files/6RDET00Gw5gvEugt4F8I" alt="Screenshots showing the steps described in this section for creating a Lookup reference"><figcaption><p>Creating a Lookup reference</p></figcaption></figure>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://help.taglo.io/calculations/calculation-parts/variable-references/lookups.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
