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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
Anonymous
Not applicable

Count Difference between dates broken out by month

Is there a way to calculate the difference between two dates but break them out by months?

 

My table example is:

IDDate StartDate EndDuration
12312/11/201816/11/20185
12302/01/201907/01/20196
100303/06/201907/08/201966

 

This count works fine for short dates within the same month but I'm hoping to get a month count between the start and end dates?

 

So I'm hoping to have some sort of breakout/ split to show:

IDJuneJulyAugust
100328317

 

Thanks.

1 ACCEPTED SOLUTION
wdx223_Daniel
Super User
Super User

@Anonymous  firstly, you need create a date table, which have no relationship with your fact table. then try this code

DaysCount :=
SUMX (
    Table1,
    VAR sd = Table1[Date Start]
    VAR ed = Table1[Date End]
    RETURN
        CALCULATE (
            COUNT ( 'Calendar'[Date] ),
            KEEPFILTERS ( DATESBETWEEN ( 'Calendar'[Date], sd, ed ) )
        )
)

wdx223_Daniel_0-1603672467586.png

 

 

View solution in original post

2 REPLIES 2
amitchandak
Super User
Super User

@Anonymous , refer if this file, I created in the past for similar problem can help

https://www.dropbox.com/s/bqbei7b8qbq5xez/leavebetweendates.pbix?dl=0

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here
wdx223_Daniel
Super User
Super User

@Anonymous  firstly, you need create a date table, which have no relationship with your fact table. then try this code

DaysCount :=
SUMX (
    Table1,
    VAR sd = Table1[Date Start]
    VAR ed = Table1[Date End]
    RETURN
        CALCULATE (
            COUNT ( 'Calendar'[Date] ),
            KEEPFILTERS ( DATESBETWEEN ( 'Calendar'[Date], sd, ed ) )
        )
)

wdx223_Daniel_0-1603672467586.png

 

 

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.