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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
Morran
Helper I
Helper I

SAMEPERIODLASTYEAR() isn't working

Dear community,

I have a question regarding time intelligence function issue. I'd like to create a measure of Total Orders - Last Year using SAMEPERIODLASTYEAR(). 

Morran_0-1698715856098.png

After I test and check the output of Year = 2014, it turns out that the Last Year value isn't blank as I expected. Instead of displaying last year result, It shows the same value with Total Orders - Current Year.

Morran_1-1698716177035.png

I have checked my calendar table and it has already marked as a date table. Do you know what makes the function not working properly? Please let me know if there anything I missed here. Thank you!
https://drive.google.com/file/d/1ivQuyeNZpC6gAAmVrGNhJ9znajy_0wPn/view?usp=sharing 

1 ACCEPTED SOLUTION
FreemanZ
Super User
Super User

hi @Morran ,

 

a VAR is a fixed value once it is defined. try like:

Total Orders - LY 2 = 
CALCULATE(
    DISTINCTCOUNT(Orders[Order ID]),
    SAMEPERIODLASTYEAR(
        'Calendar Table'[Date]
    )
)+0

 

it worked like:

FreemanZ_0-1698720814237.png

View solution in original post

2 REPLIES 2
FreemanZ
Super User
Super User

hi @Morran ,

 

a VAR is a fixed value once it is defined. try like:

Total Orders - LY 2 = 
CALCULATE(
    DISTINCTCOUNT(Orders[Order ID]),
    SAMEPERIODLASTYEAR(
        'Calendar Table'[Date]
    )
)+0

 

it worked like:

FreemanZ_0-1698720814237.png

Hi @FreemanZ , Thanks for your help, It works!

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Users online (16,877)