Check your eligibility for this 50% exam voucher offer and join us for free live learning sessions to get prepared for Exam DP-700.
Get StartedDon'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.
Is there a way to calculate the difference between two dates but break them out by months?
My table example is:
ID | Date Start | Date End | Duration |
123 | 12/11/2018 | 16/11/2018 | 5 |
123 | 02/01/2019 | 07/01/2019 | 6 |
1003 | 03/06/2019 | 07/08/2019 | 66 |
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:
ID | June | July | August |
1003 | 28 | 31 | 7 |
Thanks.
Solved! Go to Solution.
@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 ) )
)
)
@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
@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 ) )
)
)
User | Count |
---|---|
21 | |
14 | |
11 | |
7 | |
5 |
User | Count |
---|---|
23 | |
23 | |
20 | |
15 | |
10 |