OFFSET in DAX: compare with the previous row

How the OFFSET window function returns the row before or after the current one in DAX, previous month and previous product comparisons, the relation, ORDERBY and PARTITIONBY arguments, blanks, and how OFFSET compares with DATEADD and PREVIOUS.

Short answer: OFFSET ( delta, relation, ORDERBY ( ... ) [, blanks] [, PARTITIONBY ( ... )] ) returns the row delta positions away from the current row in a sorted table: -1 is the previous row, 1 the next. Used as a filter in CALCULATE, it gives "the value of the previous month" or "the next product in the ranking" without date functions: CALCULATE ( [Revenue], OFFSET ( -1, ALLSELECTED ( 'Date'[Year Month] ), ORDERBY ( 'Date'[Year Month] ) ) ). With PARTITIONBY the offset restarts in each group.

Date functions shift by calendar periods; OFFSET shifts by rows. That makes it work for orders that are not dates (the previous version, the previous step of a process) and for date axes with gaps.

What does OFFSET return?

Year MonthRevenuePrevious rowChange
2026-01120
2026-02135120+15
2026-03150135+15
2026-04142150-8
2026-05155142+13
Revenue by month with OFFSET -1
Revenue Previous Month =
CALCULATE (
    [Revenue],
    OFFSET ( -1, ALLSELECTED ( 'Date'[Year Month] ), ORDERBY ( 'Date'[Year Month] ) )
)

Change vs Previous = [Revenue] - [Revenue Previous Month]

What do the arguments do?

ArgumentMeaning
deltarows before (negative) or after (positive) the current row
relationthe table to move in; if omitted, ALLSELECTED of the ORDERBY and PARTITIONBY columns
ORDERBYhow rows are sorted; any scalar expression, ASC by default
blankswhere blanks sort: BLANKS DEFAULT, FIRST or LAST (set inside ORDERBY in newer syntax)
PARTITIONBYcolumns that define groups; the offset does not cross groups
MATCHBYcolumns that identify the current row, when ORDERBY and PARTITIONBY do not
OFFSET arguments

The current row is found by matching the visual's current values of the relation's columns. If the visual has Year and Month as separate columns, put both in the relation and the ORDERBY.

How do you restart per group?

-- previous month within the same year: January has no previous
Revenue Prev Month in Year =
CALCULATE (
    [Revenue],
    OFFSET (
        -1,
        ALLSELECTED ( 'Date'[Year], 'Date'[Month Number] ),
        ORDERBY ( 'Date'[Month Number] ),
        PARTITIONBY ( 'Date'[Year] )
    )
)

OFFSET, DATEADD or PREVIOUS?

UseWhen
DATEADD ( 'Date'[Date], -1, MONTH )calendar periods: the previous month even if it is not on the visual
OFFSET ( -1, ... )the previous row: skipping months that the filter hides, or non-date orders
PREVIOUS ( [Revenue] )a visual calculation on one visual, no model logic

If a slicer hides March, OFFSET compares April with February (the previous visible row), while DATEADD still compares with March.

What goes wrong?

  • Ties in ORDERBY. Two rows with the same sort value make "previous" ambiguous; order by a unique column.
  • Relation missing a visual column. If the visual groups by a column not in the relation, rows repeat or the result is blank; include it or use MATCHBY.
  • Sorting by a text month. "Apr" before "Feb"; order by a number or a Year Month key.
  • Totals. At the total row there is no current row to offset from; the result is usually blank.

Where can you check this?

Where do you start?

Write Revenue Previous Month with OFFSET and compare it with a DATEADD version on a chart with a month slicer. WINDOW returns several rows instead of one.

Keep reading

More from the blog.

Every post

Next

Building this? Say hello.

A question about this post, a pattern you would build differently, or the next thing you want written out: Behnia reads every message.