# DateLookback

The **DateLookback** function returns the value of a variable at a previous point in time (or lookback period) determined by a specified date and offset.

> ### 📘DateLookBack() can only be used on a grouped column where the grouping is simple DateTrunc(). If the grouping includes additional non-date columns, or if the grouping includes additional logic such as a fiscal year calculation, use a Lookup() instead.&#x20;

### Syntax

```
DateLookback(value, date, amount, period)
```

Function arguments:

|            |            |                                                                                                                                                                                                                                                                                                                                |
| ---------- | ---------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| **value**  | (required) | <p>The value to look up.</p><p>Can be a column to reference, a formula to compute, or a constant.</p><p>When referencing a column, the data must contain unique period values or be aggregated at the same date granularity as the period argument. Non-unique period values can result in null or multiple values output.</p> |
| **date**   | (required) | <p>The date to reference when offsetting the lookback period.</p><p>Can be a date, date column, or formula that returns a date.</p>                                                                                                                                                                                            |
| **amount** | (required) | <p>The number of periods to offset the lookback period.</p><p>Can be a positive integer (for lookback) or negative integer (for lookahead).</p>                                                                                                                                                                                |
| **period** | (required) | <p>The unit of time to use for the offset and lookback period.</p><p>Can be <code>"year"</code>, <code>"quarter"</code>, <code>"month"</code>, <code>"week"</code>, <code>"day"</code>, <code>"hour"</code>, <code>"minute"</code>, or <code>"second"</code>.</p>                                                              |

### Example

A table includes an *Annual Gross Profit* column containing the gross profit for each year between 2019 and 2023. You can use the **DateLookback** function to return the previous year’s gross profit and facilitate a period-over-period analysis.

```
DateLookback([Annual Gross Profit], [Year], 1, "year")
```

The formula determines a one-year offset from the period in the *Year* column, then references the offset period and returns the corresponding value from the *Annual Gross Profit* column.

<figure><img src="https://sigma-docs-screenshots.s3.us-west-2.amazonaws.com/Functions/datelookback_example.png" alt=""><figcaption></figcaption></figure>

<br>
