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
tomas12344
Helper III
Helper III

Time intelligence function working for leap year or not

I found many post and articles on web about that time intelligence functions are not woking for leap year calculations. Can someone confrim, that this issue is still present?

 

I had creted a small example, where the calendar table contains many day, including 28.5.2025 and 29.2.2024. Same for fact table. 
Then I run something like this, but only for 28.2.2025

EVALUATE
VAR StartDate = DATE ( 2008, 07, 25 )
VAR EndDate =   DATE ( 2008, 07, 31 )
RETURN
    CALCULATETABLE (
        SAMEPERIODLASTYEAR ( 'Date'[Date] ),
        Date'[Date] = Date(2025,02,28)
    )
ORDER BY [Date]

this returned the date 28.2.2024, so the exact date as selected was moved backwards 1 year.

 

But when I used the Sameperiodlastyear function in measure calculation, it returned correct values, like
Calculate(sum(), sameperiodlastyear('date'[date])
(this measure used for MTD and aslo YTD calculation for previous year, that means selecte in calendar table 28.2.2025, and needed to move back to 29.2.2024)

Model is just simple, calendar table and fact table, and between calendar and fast is relation on date column. Fact table contains only monthly snapshots, calendar contains all days

 

 

1 ACCEPTED SOLUTION
Sergii24
Super User
Super User

Hi @tomas12344, the best solution is to test it out 🙂

 

As you can see from the example below, SAMEPERIODLASTYEAR() considers leap year:

Sergii24_0-1741943263568.png

 

I always suggest to have a tehcnical measures that are showing you what period is actually selected (which might be different from what one expects 😉 )

 

Here is a code of the measure for this test:

 

Same Period Last Year = 
VAR _SamePeriodLastYear = SAMEPERIODLASTYEAR( c_Calendar[Date] )
VAR _MinDate = MINX( _SamePeriodLastYear, [Date] )
VAR _MaxDate = MAXX( _SamePeriodLastYear, [Date] )
VAR _Result = 
    IF(
        _MaxDate <> _MinDate,
        "Currently Selected Same Period Last Year: " & _MinDate & " - " & _MaxDate,
        "Currently Selected Same Period Last Year: " & _MinDate
    )
    
RETURN
    _Result

 

 

 

Good luck with your task!

View solution in original post

4 REPLIES 4
v-achippa
Community Support
Community Support

Hi @tomas12344,

 

Thank you for reaching out to Microsoft Fabric Community.

 

Thank you @Sergii24 for the prompt response.

 

As we haven’t heard back from you, we wanted to kindly follow up to check if the solution provided by the super user resolved your issue? or let us know if you need any further assistance.
If our super user response resolved your issue, please mark it as "Accept as solution" and click "Yes" if you found it helpful.

 

Thanks and regards,

Anjan Kumar Chippa

Hi @tomas12344,

 

We wanted to kindly follow up to check if the solution provided by the super user resolved your issue.

If our super user response resolved your issue, please mark it as "Accept as solution" and click "Yes" if you found it helpful.

 

Thanks and regards,

Anjan Kumar Chippa

Hi @tomas12344,

 

As we haven’t heard back from you, we wanted to kindly follow up to check if the solution provided by the super user resolved your issue.
If our super user response resolved your issue, please mark it as "Accept as solution" and click "Yes" if you found it helpful.

 

Thanks and regards,

Anjan Kumar Chippa

Sergii24
Super User
Super User

Hi @tomas12344, the best solution is to test it out 🙂

 

As you can see from the example below, SAMEPERIODLASTYEAR() considers leap year:

Sergii24_0-1741943263568.png

 

I always suggest to have a tehcnical measures that are showing you what period is actually selected (which might be different from what one expects 😉 )

 

Here is a code of the measure for this test:

 

Same Period Last Year = 
VAR _SamePeriodLastYear = SAMEPERIODLASTYEAR( c_Calendar[Date] )
VAR _MinDate = MINX( _SamePeriodLastYear, [Date] )
VAR _MaxDate = MAXX( _SamePeriodLastYear, [Date] )
VAR _Result = 
    IF(
        _MaxDate <> _MinDate,
        "Currently Selected Same Period Last Year: " & _MinDate & " - " & _MaxDate,
        "Currently Selected Same Period Last Year: " & _MinDate
    )
    
RETURN
    _Result

 

 

 

Good luck with your task!

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.

Top Solution Authors