SAMEPERIODLASTYEAR (Year-over-Year)

Power BI · Advanced DAX & Time Intelligence

Theory

SAMEPERIODLASTYEAR(dates) returns the dates in the current filter context shifted back by one year. Used inside CALCULATE, it gives the value of a measure for the same period last year: if the current cell is March 2024, it returns the dates of March 2023. From there, year-over-year growth is a simple DIVIDE of the difference by last year's value.

With the sample history, January 2024 sales are ₹1,200 versus ₹1,000 in January 2023, a 20.0% increase; February is ₹2,300 versus ₹1,800 (27.8%); March is ₹2,200 versus ₹2,500, a fall of 12.0%. It works at any granularity: on a year row it compares the full year, on a quarter row the quarter. The date table must contain both years, so a calendar built only for 2024 would return blank for last year. SAMEPERIODLASTYEAR is equivalent to DATEADD(dates, -1, YEAR).

Why we use it

Year-over-year comparison removes the effect of seasonality and is the standard way businesses judge growth, so almost every sales report needs it.

When to use it

Use it for same-period comparisons with last year at any level (month, quarter, year). For shifts other than one year, such as previous month, use DATEADD; for full previous-year totals regardless of the period, use PREVIOUSYEAR or PARALLELPERIOD.

How it works

  1. Visual cell: Mar 2024
  2. Read the current dates (1-31 Mar 2024)
  3. SAMEPERIODLASTYEAR shifts them to 1-31 Mar 2023
  4. CALCULATE evaluates Total Sales on the shifted dates
  5. Does last year have data? Yes: Compute YoY % with DIVIDE. No: Show blank.
  6. Current vs last year side by side

Syntax

SAMEPERIODLASTYEAR(<dates>)
Sales LY = CALCULATE([Total Sales], SAMEPERIODLASTYEAR('Date'[Date]))
YoY % = DIVIDE([Total Sales] - [Sales LY], [Sales LY])

Example

Sales LY = 
CALCULATE(
    [Total Sales],
    SAMEPERIODLASTYEAR('Date'[Date])
)

YoY % = 
VAR Cur = [Total Sales]
VAR Prev = [Sales LY]
RETURN DIVIDE(Cur - Prev, Prev)
// Mar 2024: (2,200 - 2,500) / 2,500 = -12.0%

Key points

Power BI topics

Power BI Introduction

Getting Data

Power Query (Data Transformation)

Data Modeling

DAX (Data Analysis Expressions)

Data Visualization

Dashboards & Reports

Power BI Service

Advanced Features

Projects & Case Studies

Interview & Certification

Advanced DAX & Time Intelligence

T
Tech Town
Log InSign Up Free
Home SQL Python DSA Power BI Snowflake Databricks Spark Gen AI Practice Problems Contest Blog

Power BI Dashboards & DAX

Learn data visualization and interactive dashboards step-by-step. Click any topic in the sidebar to open it right here.

{{ sectionCount }}
Sections
{{ topicCount }}
Topics
Free
Forever
Hands-on practice Practice DAX Online 250 business scenarios on a star schema — write a measure and compare your visual with the expected one. Start practising →
Section {{ sec.num }}

{{ sec.label }}

Power BI  /  {{ current.sectionLabel }}  /  {{ current.name }}

{{ current.name }}

Theory

{{ current.def }}

Why we use it

{{ rich.why }}

When to use it

{{ rich.when }}

Diagram

{{ rich.dg.caption }}

{{ tb.title }}
{{ c.v }}
{{ rich.dg.op }}
➜
{{ rich.dg.output.title }}
{{ c.v }}
{{ nd.label }}
{{ nd.sub }}
{{ nd.label }}
{{ nd.sub }}
{{ rich.dg.left.title }}
{{ it }}
{{ rich.dg.right.title }}
{{ it }}
On screen — where to click

{{ rich.ui.title }}

{{ u.text }}
  1. {{ st.n }}{{ st.text }}
{{ rich.ui.title }}
{{ u.text }}
Flowchart — how it works
{{ nd.text }}
{{ nd.text }}
◇ {{ nd.text }}
Yes → {{ nd.yes }}
No → {{ nd.no }}
Syntax / Where to find it
{{ current.syntax }}
Example
{{ current.example }}
What You'll Learn — click to check off
  • {{ pt.mark }} {{ pt.text }}

Share this topic