Microsoft is giving away 50,000 FREE Microsoft Certification exam vouchers. Get Fabric certified for FREE! Learn more
Hi, I have 2 dog boarding kennels and want to know the day count between the previous Dog ending and new one starting for each room.
For example, the day difference between Dog1 and Dog2 in April 2024 A1 is 2 days.
I do not have the Days_to_Fill column in my source data.
Location | Room | Dog_Number | Start_Date | End_Date | Days_to_Fill |
Manchester | A1 | 1 | 01/04/2024 | 10/04/2024 | 2 |
Manchester | A1 | 2 | 13/04/2024 | 18/04/2024 | 7 |
Manchester | A1 | 3 | 26/04/2024 | 28/04/2024 | 5 |
Manchester | A1 | 4 | 03/05/2024 | 15/05/2024 | |
Newcastle | B1 | 5 | 01/07/2024 | 12/07/2024 | 4 |
Newcastle | B1 | 6 | 17/07/2024 | 23/07/2024 | 15 |
Newcastle | B1 | 7 | 08/08/2024 | 18/08/2024 | 2 |
Newcastle | B1 | 8 | 21/08/2024 | 25/08/2024 |
Thanks
Solved! Go to Solution.
It is a calculated column
Difference =
VAR NextStart =
CALCULATE (
MIN ( 'Table'[Start_Date] ),
FILTER (
ALL ( 'Table' ),
'Table'[Room] = EARLIER ( 'Table'[Room] )
&& 'Table'[Start_Date] > EARLIER ( 'Table'[Start_Date] )
)
)
RETURN
DATEDIFF ( 'Table'[End_Date], NextStart, DAY )
DAX for a Calculated Column:
Days_to_Fill =
VAR CurrentStart = 'Table'[Start_Date]
VAR CurrentRoom = 'Table'[Room]
VAR CurrentLocation = 'Table'[Location]
VAR PreviousEnd =
MAXX(
FILTER(
'Table',
'Table'[Room] = CurrentRoom &&
'Table'[Location] = CurrentLocation &&
'Table'[End_Date] < CurrentStart
),
'Table'[End_Date]
)
RETURN
IF(
NOT ISBLANK(PreviousEnd),
DATEDIFF(PreviousEnd, CurrentStart, DAY),
BLANK()
)
💌 If this helped, a Kudos 👍 or Solution mark ✅ would be great! 🎉
Cheers,
Kedar
Connect on LinkedIn
I'm pretty confused
Row 1: Apr 10 to 13 = 3 days
Row 2 : Apr 18 to Apr 26 = 8 days
These should be the differences in days
Location | Room | Dog_Number | Start_Date | End_Date | Days_to_Fill | difference |
Manchester | A1 | 1 | 01/04/2024 | 10/04/2024 | 2 | 3 |
Manchester | A1 | 2 | 13/04/2024 | 18/04/2024 | 7 | 8 |
Manchester | A1 | 3 | 26/04/2024 | 28/04/2024 | 5 | 5 |
Manchester | A1 | 4 | 03/05/2024 | 15/05/2024 | ||
Newcastle | B1 | 5 | 01/07/2024 | 12/07/2024 | 4 | 5 |
Newcastle | B1 | 6 | 17/07/2024 | 23/07/2024 | 15 | 16 |
Newcastle | B1 | 7 | 08/08/2024 | 18/08/2024 | 2 | 3 |
Newcastle | B1 | 8 | 21/08/2024 | 25/08/2024 |
It is a calculated column
Difference =
VAR NextStart =
CALCULATE (
MIN ( 'Table'[Start_Date] ),
FILTER (
ALL ( 'Table' ),
'Table'[Room] = EARLIER ( 'Table'[Room] )
&& 'Table'[Start_Date] > EARLIER ( 'Table'[Start_Date] )
)
)
RETURN
DATEDIFF ( 'Table'[End_Date], NextStart, DAY )
This worked perfectly thank you!
Hi @RichOB ,
Please try below DAX :
Hi @AnkitaaMishra thanks so much for your help. I'm having a DAX error of " Cannot convert value 'Manchester' of type Text to type True/False". Do you know how I would solve this please?
Check out the April 2025 Power BI update to learn about new features.
Explore and share Fabric Notebooks to boost Power BI insights in the new community notebooks gallery.
User | Count |
---|---|
76 | |
74 | |
69 | |
47 | |
41 |
User | Count |
---|---|
63 | |
42 | |
30 | |
29 | |
28 |