Power BI is turning 10! Tune in for a special live episode on July 24 with behind-the-scenes stories, product evolution highlights, and a sneak peek at what’s in store for the future.
Save the dateEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
![]()
So above is an example of my dataset. First I arranged all the names on alphabetic order and column test end date is also ordered from new to old.
I arranged these in Power Query. What I would like to know is, how to calculate the days between the end date per person and the next start date per person, in days.
So far I tried the following DAX-code:
Link: (51) Calculate Break time between two consecutive Group by Rows in Power BI - YouTube
The DAX-code above doens't work, after arranging the data in Power Query. If I don't arrange the data, then the code works.
But it can sometimes give the wrong amount of calculated days, because the dates are not arranged.
So how can I calculate the days between the last date and the next start date per person?
Note: I am new to Power BI and English is also not my first language. Thank you.
Solved! Go to Solution.
@Anonymous You can just subtract the dates and multiply by 1 to make sure it returns a number. You can use MTBF. See my article on Mean Time Between Failure (MTBF) which uses EARLIER: http://community.powerbi.com/t5/Community-Blog/Mean-Time-Between-Failure-MTBF-and-Power-BI/ba-p/339586.
The basic pattern is:
Column =
VAR __Current = [Value]
VAR __PreviousDate = MAXX(FILTER('Table','Table'[Date] < EARLIER('Table'[Date])),[Date])
VAR __Previous = MAXX(FILTER('Table',[Date]=__PreviousDate),[Value])
RETURN
__Current - __Previous
Hi @Anonymous
please try
Days between =
VAR CurrentStarDate = 'Report As Actual'[Start Date]
VAR CurrentEndDate = 'Report As Actual'[End Date]
VAR CurrentNameTable =
CALCULATETABLE (
'Report As Actual',
ALLEXCEPT ( 'Report As Actual', 'Report As Actual'[Name] )
)
VAR DatesAfter =
FILTER ( CurrentNameTable, 'Report As Actual'[Start Date] > CurrentStarDate )
VAR NextStartDate =
MINX ( DatesAfter, 'Report As Actual'[Start Date] )
RETURN
IF (
NOT ISBLANK ( NextStartDate ),
DATEDIFF ( CurrentEndDate, NextStartDate, DAY )
)
Hi @Anonymous
please try
Days between =
VAR CurrentStarDate = 'Report As Actual'[Start Date]
VAR CurrentEndDate = 'Report As Actual'[End Date]
VAR CurrentNameTable =
CALCULATETABLE (
'Report As Actual',
ALLEXCEPT ( 'Report As Actual', 'Report As Actual'[Name] )
)
VAR DatesAfter =
FILTER ( CurrentNameTable, 'Report As Actual'[Start Date] > CurrentStarDate )
VAR NextStartDate =
MINX ( DatesAfter, 'Report As Actual'[Start Date] )
RETURN
IF (
NOT ISBLANK ( NextStartDate ),
DATEDIFF ( CurrentEndDate, NextStartDate, DAY )
)
@Anonymous You can just subtract the dates and multiply by 1 to make sure it returns a number. You can use MTBF. See my article on Mean Time Between Failure (MTBF) which uses EARLIER: http://community.powerbi.com/t5/Community-Blog/Mean-Time-Between-Failure-MTBF-and-Power-BI/ba-p/339586.
The basic pattern is:
Column =
VAR __Current = [Value]
VAR __PreviousDate = MAXX(FILTER('Table','Table'[Date] < EARLIER('Table'[Date])),[Date])
VAR __Previous = MAXX(FILTER('Table',[Date]=__PreviousDate),[Value])
RETURN
__Current - __Previous
Check out the July 2025 Power BI update to learn about new features.
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
User | Count |
---|---|
20 | |
7 | |
6 | |
5 | |
5 |
User | Count |
---|---|
26 | |
10 | |
10 | |
9 | |
6 |