Power BI is turning 10, and we’re marking the occasion with a special community challenge. Use your creativity to tell a story, uncover trends, or highlight something unexpected.
Get startedJoin us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.
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?
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
Check out the June 2025 Power BI update to learn about new features.
User | Count |
---|---|
68 | |
58 | |
51 | |
36 | |
34 |
User | Count |
---|---|
84 | |
71 | |
56 | |
45 | |
43 |