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

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes! Register now.

Reply
Data5
New Member

Count Number of Months per Year a project is running given a start date and an end date

Given a field labeled "Start Date" with data of 11/5/2023 and a second field labeled "End Date" with date of 3/15/2025, how do I add columns of 2023 Month Count, 2024 Month Count and 2025 Month Count with expected results of 2, 12 and 3, respectively?  I'm open to either Dax or PowerQuery examples whichever is most efficient would be preferred though.  Thank you!

1 ACCEPTED SOLUTION
Anonymous
Not applicable

HI @Data5,

It sound like a common multiple date fields analysis requirement, I'd like to suggest you take a look at the following start/end date part if them suitable for your scenario:
Before You Post, Read This: start, end date  

Regards,

Xiaoxin Sheng

View solution in original post

2 REPLIES 2
Data5
New Member

Thanks for the suggestion.  I ended up using the code below:

2024 Month Count =
IF (
    YEAR ( [Start date] ) = 2024,
    DATEDIFF ( [Start date], DATE ( 2024, 12, 31 ), MONTH )+1,
    IF (
        YEAR ( [Start date] ) = 2024 && YEAR ( [End Date] ) = 2024,
        DATEDIFF ( [Start date], [End Date], MONTH )+1,
        IF (
            YEAR ( [End Date] ) = 2024,
            DATEDIFF ( DATE ( 2024, 12, 31 ), [End Date], MONTH )+12,
            IF (
                AND(YEAR([Start Date]) < 2024, YEAR([End Date]) > 2024),
                12,
                0
            )
        )
    )
)

 

Anonymous
Not applicable

HI @Data5,

It sound like a common multiple date fields analysis requirement, I'd like to suggest you take a look at the following start/end date part if them suitable for your scenario:
Before You Post, Read This: start, end date  

Regards,

Xiaoxin Sheng

Helpful resources

Announcements
September Power BI Update Carousel

Power BI Monthly Update - September 2025

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

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.

Top Solution Authors