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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply

SAMEPERIODLASTYEAR not working with Date Key

I have a fact table, and a date table (marked as a date table in my report).  I'm trying to do a visual comparing this year's calls with prior year's calls (user selects a year from a slicer).  I've tried the following DAX measures, neither of which works:

 

Calls Prior Year = CALCULATE(DISTINCTCOUNT(Cad_Call[CC_rin]), USERELATIONSHIP(Cad_Call[DateKey_occur], DateList[DateKey]), Cad_Call[service_call] = "Y", SAMEPERIODLASTYEAR(Cad_Call[DateKey_occur])) + 0

 

Calls Prior Year = CALCULATE(DISTINCTCOUNT(Cad_Call[CC_rin]), USERELATIONSHIP(Cad_Call[DateKey_occur], DateList[DateKey]), Cad_Call[service_call] = "Y", SAMEPERIODLASTYEAR(DateList[DateKey])) + 0

 

There is no error when I save the measure, but the visual throws this error:  A column spedified in the call to function SAMEPERIODLASTYEAR is not of typye DATE.  This is not supported.

 

When I look at the MS DAX page, it looks like I should be able to use a date key in the SAMEPERIODLASTYEAR function.

When I change the formula to this: 

Calls Prior Year = CALCULATE(DISTINCTCOUNT(Cad_Call[CC_rin]), USERELATIONSHIP(Cad_Call[DateKey_occur], DateList[DateKey]), Cad_Call[service_call] = "Y", SAMEPERIODLASTYEAR(DateList[Date])) + 0
 

I get the visual up, but it lists ALL years data, not just the data for the year I selected from the slicer.

I'm not sure what I'm doing wrong?

Thanks for any help!

1 ACCEPTED SOLUTION
Anonymous
Not applicable

HI @PowerBIkalaimo ,

I'd like to suggest you to use the date function to manually defined filter date range instead to use time intelligence functions:

Time Intelligence "The Hard Way" (TITHW)

Regards,

Xiaoxin Sheng

View solution in original post

1 REPLY 1
Anonymous
Not applicable

HI @PowerBIkalaimo ,

I'd like to suggest you to use the date function to manually defined filter date range instead to use time intelligence functions:

Time Intelligence "The Hard Way" (TITHW)

Regards,

Xiaoxin Sheng

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.