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
MarcoT
Frequent Visitor

SAMEPERIODLASTYEAR not working on previous year

Hi, I'm pretty new to PowerBI and I appreciate this forum to share experiences.

I've a problem with a measure not displaying the correct value. I've a fact table called Summary in which I've the field [Prepared Quantity] on wich I've created this measure:


Deliberated Lines TOT = CALCULATE(SUM('Summary'[Prepared Quantity]), GROUPBY('Summary','Summary'[Planned Delivery Date],'Summary'[Shipment Type],'Summary'[FLG Prep]))

 

where [Planned Delivery Date] is a non-unique field of type date.

What I would like to do is displaying the same value but one year before the selected date or the date in the visual row. I tried to use the SAMEPERIODLASTYEAR with [Planned Delivery Date] but it gave me an error because the date rows are not unique. So I added a calendar table in order to do that and I linked the [Planned Delivery Date Id] field to the calendar key of the calendar dimension. After that I've created this measure:

 


Deliberated Lines TOT Previous Year = CALCULATE('Summary'[Deliberated Lines TOT],ALL('Calendar'[Date Value]),SAMEPERIODLASTYEAR('Calendar'[Date Value])) 

 

but it shows me the same value of the [Deliberated Lines TOT] measure.

Here's a screenshot:

 

MarcoT_0-1661705162566.png

What I'm doing wrong?

Thanks in advance

 

1 ACCEPTED SOLUTION

@MarcoT 

For Week in Year Number make sure tgat you select "Do not summarize" also make sure that 'Calendar' is marked as date table with Date Value as the date column. Then the following should technically work. 

Deliberated Lines TOT Previous Year =
CALCULATE (
    'Summary'[Deliberated Lines TOT],
    ALL ( 'Calendar' ),
    SAMEPERIODLASTYEAR ( 'Calendar'[Date Value] )
)

View solution in original post

3 REPLIES 3
tamerj1
Super User
Super User

Hi @MarcoT 

In your table visual, Instead of Planned Delivery Date please use 'Calendar'[Date] and instead of Week Planned Delivery Date use 'Calender'[Week Number] 

Hi, I've done it but now but unfortunately it shows no results. Here's a screenshot:

MarcoT_0-1661711956019.png

 

@MarcoT 

For Week in Year Number make sure tgat you select "Do not summarize" also make sure that 'Calendar' is marked as date table with Date Value as the date column. Then the following should technically work. 

Deliberated Lines TOT Previous Year =
CALCULATE (
    'Summary'[Deliberated Lines TOT],
    ALL ( 'Calendar' ),
    SAMEPERIODLASTYEAR ( 'Calendar'[Date Value] )
)

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.