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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

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
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

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

Top Solution Authors