# Compare periods
URL: https://docs.valsight.ai/compare-periods/
Description: Use this category when you need to compare values across time, such as month-over-month or year-over-year changes.
Use this category when you need to **compare values across time**, such as month-over-month or year-over-year changes.

These functions help you shift values to a reference period and compute absolute or relative deltas.

## Start here if you want to:

* Compare a metric to the **previous period**, such as month, quarter, year, or week
* Use **standard growth metrics** such as `MOM`, `QOQ`, `YOY`
* Choose between **absolute and relative changes**, for example a difference or a percentage change
* Calculate **compound growth over multiple periods** with `CAGR`

## Not here if you want to:

* Use cumulative totals or projections → see [Rollforward & time series](/rollforward-time-series/)
* Reshape dimensionality first → see [Dimensionality & hierarchies](/dimensionality-hierarchies/)

## Mental model

* **Shift**: move values along a time level to align the current period with a reference period
* **Compare**: compute change vs a reference period as an absolute or relative difference
* **Compound**: compute a compounded growth rate from a start value to an end value across multiple periods

Most compare-period functions keep the same output shape as the input node.

## Common patterns

| Name                           | What it does                                                                 | Formula                                                    |
| ------------------------------ | ---------------------------------------------------------------------------- | ---------------------------------------------------------- |
| Compare to previous year       | Use when you want to compute relative year-over-year change.                 | `YOY_REL('Sales')`                                         |
| Compute a generic delta        | Use when you want the absolute change along a specific level.                | `DELTA_ABS('Sales', "Quarter")`                            |
| Shift values                   | Use when you need explicit alignment before doing your own arithmetic.       | `SHIFT('Sales', "Month", -1)`                              |
| Use period shortcuts           | Use when you want a direct previous-period series to combine with operators. | `PM('Sales')`, `PQ('Sales')`, `PY('Sales')`, `PW('Sales')` |
| Compound growth over N periods | Use when you want a compounded annual growth rate over N periods.            | `CAGR('Sales', 3)`                                         |

## Functions in this category

**Shift helpers**

| Function         | Description                                                                     |
| ---------------- | ------------------------------------------------------------------------------- |
| [SHIFT](/shift/) | Shifts values along a specified level by a given offset (positive or negative). |
| [PM](/pm/)       | Returns the values for the previous month.                                      |
| [PQ](/pq/)       | Returns the values for the previous quarter.                                    |
| [PY](/py/)       | Returns the values for the previous year.                                       |
| [PW](/pw/)       | Returns the values for the previous week.                                       |

**Generic delta functions**

| Function                  | Description                                                                                  |
| ------------------------- | -------------------------------------------------------------------------------------------- |
| [DELTA\_ABS](/delta-abs/) | Calculates the absolute difference between consecutive values within the selected dimension. |
| [DELTA\_REL](/delta-rel/) | Calculates the relative difference between consecutive values within the selected dimension. |

**Standard period comparisons**

| Function              | Description                                                                    |
| --------------------- | ------------------------------------------------------------------------------ |
| [MOM\_ABS](/mom-abs/) | Returns absolute month-over-month growth compared to the previous month.       |
| [MOM\_REL](/mom-rel/) | Returns relative month-over-month growth compared to the previous month.       |
| [QOQ\_ABS](/qoq-abs/) | Returns absolute quarter-over-quarter growth compared to the previous quarter. |
| [QOQ\_REL](/qoq-rel/) | Returns relative quarter-over-quarter growth compared to the previous quarter. |
| [WOW\_ABS](/wow-abs/) | Returns absolute week-over-week growth compared to the previous week.          |
| [WOW\_REL](/wow-rel/) | Returns relative week-over-week growth compared to the previous week.          |
| [YOY\_ABS](/yoy-abs/) | Returns absolute year-over-year growth compared to the previous year.          |
| [YOY\_REL](/yoy-rel/) | Returns relative year-over-year growth compared to the previous year.          |

**Compound growth**

| Function       | Description                                                                    |
| -------------- | ------------------------------------------------------------------------------ |
| [CAGR](/cagr/) | Calculates the compound annual growth rate over a specified number of periods. |

## Choosing between similar functions

**CAGR vs YOY\_REL (or other REL deltas)**

* Use `YOY_REL` when you want a single-period relative change vs last year
* Use `CAGR` when you want compounded growth across multiple periods

**DELTA\_* vs MOM/QOQ/YOY/WOW*\*

* Use `MOM`, `QOQ`, `YOY`, or `WOW` for common standard comparisons
* Use `DELTA_ABS` or `DELTA_REL` when you want a delta without filling missing values

**ABS vs REL**

* Use `ABS` when you need a difference in the same unit as the measure, for example EUR
* Use `REL` when you need a relative change, for example a growth rate

**SHIFT vs PM/PQ/PY/PW**

* Use `PM`, `PQ`, `PY`, or `PW` when previous month, quarter, year, or week is exactly what you want
* Use `SHIFT` when you need a custom offset or a specific time level

## Pitfalls & troubleshooting

* **Unexpectedly empty output**: check whether the reference period exists for those slices and whether missing values propagate through your calculation
* **Misalignment**: confirm the time level you are operating on, for example month vs quarter vs year
* `CAGR` **errors or gaps**: check whether the start and end values exist for the slice, whether `NumberOfPeriods` is a whole number greater than or equal to `1`, and whether you need a different invalid-handling behavior
* **Behavior options**: if a function supports options such as `FirstValueBehavior` or `MissingValueBehavior`, verify which option is active and whether it matches your expectation

## Related

* [Rollforward & time series](/rollforward-time-series/): running totals, moving windows, projections
* [Operators](/operators/): combine current vs reference values using arithmetic and comparisons
* [Formula basics](/formula-basics/): evaluation order, constants, and notation
* [Troubleshooting guide](/troubleshooting-guide/): missing values, wrong shape, unexpected results
