Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
stuart765
Frequent Visitor

SAMEPERIODLASTYEAR Problem

 

I am attempting to create a dashboard (cards) showing current year revenue (SP Revenue CY) vs. previous year revenue (SP Revenue Previous Year) and have the DAX commands listed below for each.

 

1. SP Revenue CY = SUM('SP Sold Rxs 1_1_2020 through Present 12_26_2022'[Revenue Validated])
 
2. SP Revenue Previous Year = CALCULATE('SP Sold Rxs 1_1_2020 through Present 12_26_2022'[SP Revenue CY],SAMEPERIODLASTYEAR('SP Sold Rxs 1_1_2020 through Present 12_26_2022'[Month-Year].[Date]))
 
I added a calendar table and joined it with the main data table. A dropdown was created for Year, Month, Day so I could compare different timeframes (e.g., first 14 days of month vs previous year's month first 14 days). I only see data for the entire month whether I choose Day1, Days 1-15 and/or Days 21-30.
 
Any suggestions on how to 
1 ACCEPTED SOLUTION
FreemanZ
Super User
Super User

hi @stuart765 

try like:

SP Revenue Previous Year = 
CALCULATE(
    SPTable [SP Revenue CY],
    DATEADD(CalendarTable[Date], -1, MONTH)
)
 
Please let me know if it works, then we say why SAMEPERIODLASTYEAR is not working.

View solution in original post

2 REPLIES 2
stuart765
Frequent Visitor

I used the formula referenced and Previous Year Revenue did not return a value. It was blank.

FreemanZ
Super User
Super User

hi @stuart765 

try like:

SP Revenue Previous Year = 
CALCULATE(
    SPTable [SP Revenue CY],
    DATEADD(CalendarTable[Date], -1, MONTH)
)
 
Please let me know if it works, then we say why SAMEPERIODLASTYEAR is not working.

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.