Forum Discussion

AlienBI's avatar
AlienBI
Frequent Visitor
11 months ago
Solved

Issue with SAMETIMELASTYEAR

Hi there, 

I'm having troubles with SAMETIMELASTYEAR. I want to show what the revenue was LY at the same time in the table below from April 2025 to September 2025. I have a date filter for this, but it doesn't apply to my LY calculation - it shows data beyond September 25.
How do I make it work?

See here PBIX link and below for details:

 

My LY measure is :

LY_T&K = CALCULATE(sum('RA Subset'[T&K]),ALLEXCEPT('Calendar','Calendar'[Date].[Date]),SAMEPERIODLASTYEAR('Calendar'[Date].[Date]))

My calendar table is:
Calendar = CALENDAR(Date(2024,07,01),Date(2025,09,30))
Thanks for your help!

 







2 Replies

  • Hi AlienBI 

    First, as a best practice, dispable auto-datetime and explicity create date element columns (year, month, quarter, etc). Auto-datetime creates an invisible table of dates for almost all date columns in your model and thus take up space.

     

    Modify your formula to below:

    CALCULATE (
        SUM ( 'RA Subset'[T&K] ),
        SAMEPERIODLASTYEAR ( 'Calendar'[Date] )
    )
    

    Ensure that the date/calendar table has been marked as such - Set and use date tables in Power BI Desktop . If not you will have to explicityly include a REMOVEFILTERS to your measure.

    CALCULATE (
        SUM ( 'RA Subset'[T&K] ),
        SAMEPERIODLASTYEAR ( 'Calendar'[Date] ),
        REMOVEFILTERS ( 'Calendar' )
    )