OFFSET vs LAG vs LEAD in Anaplan

All three read a value from another period. A positive number looks forward in OFFSET and LEAD, and back in LAG. LAG and LEAD can also block zero or negative offsets. For one period, use PREVIOUS or NEXT.

By , Anaplan architect at MaxPlan and Master Anaplanner. Updated .

What is the difference between OFFSET, LAG and LEAD?

OFFSET(Value to offset, Offset amount, Substitute value[, List])
LAG(Value to offset, Offset amount, Substitute value[, Non-positive behavior[, List]])
LEAD(Value to offset, Offset amount, Substitute value[, Non-positive behavior[, List]])
OFFSET, LAG and LEAD compared
OFFSETLAGLEAD
Positive amount readsA later periodAn earlier periodA later period
Negative amount readsAn earlier periodA later period, unless blockedAn earlier period, unless blocked
Outside the timelineSubstitute valueSubstitute valueSubstitute value
Over a listPolaris onlyPolaris onlyPolaris only

OFFSET is the same as LEAD in its default mode.

OFFSET, LAG and LEAD examples

Two months ago, one month ahead, and one month ago:

LAG(Orders.Quantity, 2, 0)
LEAD(Orders.Quantity, 1, 0)
OFFSET(Orders.Quantity, -1, 0)
OFFSET, LAG and LEAD results over four months
JanFebMarApr
Quantity10203040
LAG by 2001020
LEAD by 12030400
OFFSET by -10102030

For exactly one period, PREVIOUS and NEXT are shorter. For last year's total to date, see prior-year YTD.

What do STRICT, SEMISTRICT and NONSTRICT do?

They decide what LAG and LEAD return when the amount is zero or negative.

LAG and LEAD non-positive behavior
KeywordPositiveZeroNegative
NONSTRICT (default)ValueValueValue
SEMISTRICTValueValueSubstitute
STRICTValueSubstituteSubstitute

Use it when the amount is data, so a wrong negative lead time can't read the future:

LAG(Orders.Quantity, Products.Lead time, 0, SEMISTRICT)

When should you use POST instead?

LAG reads one value. POST sends values to other periods and adds up those that land together. If the lead time changes by month, two months' orders can arrive in the same month, and only POST adds both:

POST(Orders.Quantity, Orders.Lead time)

Planual 2.02-13 says to use POST only when more than one value can apply, because OFFSET, LAG and MOVINGSUM cost much less to calculate.

What changes between Classic and Polaris?

Classic works over Time only. For LAG and LEAD, it cuts a decimal amount toward zero and Polaris rounds it: 1.7 is 1 in Classic and 2 in Polaris. A NaN amount counts as 0 in Classic and gives the substitute value in Polaris. In Classic, LAG and LEAD on anything but a number need a constant amount.

A relative function is also safer than naming a month. Check your own model for hard-coded time periods.

Sources

Check your model

Upload the line-items blueprint. The basic check runs in your browser and needs no email.

Check your model