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

Did you hear? There's a new SQL AI Developer certification (DP-800). Start preparing now and be one of the first to get certified. Register now

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
Community Champion
Community Champion

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
Community Champion
Community Champion

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
April Power BI Update Carousel

Power BI Monthly Update - April 2026

Check out the April 2026 Power BI update to learn about new features.

New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.