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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
Mattiar
Resolver I
Resolver I

Bug Report: DATESINPERIOD Function – Leap Year Handling

I’d like to report a bug in the DATESINPERIOD function:

DATESINPERIOD (
         'Data'[data],
         SELECTEDVALUE ( 'Data'[data] ),
         -1,
         YEAR
)

When I select the exact date of February 28, 2025, it should go back to February 29, 2024, as stated in the documentation, but it doesn’t handle the leap year day properly.

Mattiar_0-1742477643502.png

This could lead to misunderstandings in reports.

 

Mattia

2 ACCEPTED SOLUTIONS

Thanks, Greg,
your links are always relevant.
"Unfortunately," I share your opinion about the TI functions, but at the same time, I hope they will be improved and cleaned of their bugs over time.

View solution in original post

A workaround was to propose a month-year selector instead of the date field. This way, you don’t have any issues. I’m reporting the measure for completeness.

 

var _ultimodelmese =

CALCULATE(

    MAX('Data'[data]),

    ALLEXCEPT('Data', 'Data'[anno], 'Data'[mese_anno])

)

RETURN

 

CALCULATE(

    [Amount],

    DATESINPERIOD(

        'Data'[data],

        _ultimodelmese,

        -1,

        YEAR

    )

)

View solution in original post

3 REPLIES 3
Greg_Deckler
Community Champion
Community Champion

@Mattiar Yeah, in general, stay away from the DAX TI functions IMHO. You may find this helpful - https://community.powerbi.com/t5/Community-Blog/To-bleep-With-Time-Intelligence/ba-p/1260000

Also, see if my Time Intelligence the Hard Way provides a different way of accomplishing what you are going for.

https://community.powerbi.com/t5/Quick-Measures-Gallery/Time-Intelligence-quot-The-Hard-Way-quot-TIT...



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

Thanks, Greg,
your links are always relevant.
"Unfortunately," I share your opinion about the TI functions, but at the same time, I hope they will be improved and cleaned of their bugs over time.

A workaround was to propose a month-year selector instead of the date field. This way, you don’t have any issues. I’m reporting the measure for completeness.

 

var _ultimodelmese =

CALCULATE(

    MAX('Data'[data]),

    ALLEXCEPT('Data', 'Data'[anno], 'Data'[mese_anno])

)

RETURN

 

CALCULATE(

    [Amount],

    DATESINPERIOD(

        'Data'[data],

        _ultimodelmese,

        -1,

        YEAR

    )

)

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.