This time we’re going bigger than ever. Fabric, Power BI, SQL, AI and more. We're covering it all. You won't want to miss it.
Learn moreLevel up your Power BI skills this month - build one visual each week and tell better stories with data! Get started
Hi,
I'd like to calculate the difference between dates, splited in different rows, returing the difference in the format "Days Hours".
Do you guys have any idea?
The table is already ordered by "Planta"and Datetime (ASC order). If there is no previous record, it can return null.
Thanks in advance community 🙂
Table example
| Planta | Datetime | Date | Index | Index.1 | datediff |
| Aglaonema | 15/1/25 9:01 | 15/01/2025 | 10 | 11 | |
| Aglaonema | 18/1/25 16:31 | 18/01/2025 | 9 | 10 | |
| Aglaonema | 22/1/25 8:50 | 22/01/2025 | 8 | 9 | |
| Aglaonema | 27/1/25 10:24 | 27/01/2025 | 7 | 8 | |
| Aglaonema | 1/2/25 15:14 | 01/02/2025 | 6 | 7 | |
| Aglaonema | 3/2/25 13:05 | 03/02/2025 | 5 | 6 | |
| Aglaonema | 5/2/25 10:22 | 05/02/2025 | 4 | 5 | |
| Alecrim | 19/9/24 8:04 | 19/09/2024 | 49 | 50 | |
| Alecrim | 21/9/24 9:53 | 21/09/2024 | 48 | 49 | |
| Alecrim | 23/9/24 9:39 | 23/09/2024 | 47 | 48 | |
| Alecrim | 25/9/24 10:30 | 25/09/2024 | 46 | 47 | |
| Alecrim | 26/9/24 7:59 | 26/09/2024 | 45 | 46 | |
| Alecrim (2025-01) | 21/1/25 17:03 | 21/01/2025 | 53 | 54 | |
| Alecrim (2025-01) | 22/1/25 10:31 | 22/01/2025 | 52 | 53 | |
| Alecrim (2025-01) | 23/1/25 10:57 | 23/01/2025 | 51 | 52 | |
| Alecrim (2025-01) | 3/2/25 13:13 | 03/02/2025 | 50 | 51 | |
| Aloe Aristata | 19/9/24 8:04 | 19/09/2024 | 65 | 66 | |
| Aloe Aristata | 23/9/24 9:39 | 23/09/2024 | 64 | 65 | |
| Aloe Aristata | 26/9/24 8:10 | 26/09/2024 | 63 | 64 | |
| Aloe Aristata | 29/9/24 10:09 | 29/09/2024 | 62 | 63 | |
| Aloe Aristata | 1/10/24 15:15 | 01/10/2024 | 61 | 62 |
Solved! Go to Solution.
Hi @leorrn - Please find the attached pbix you can use DAX to calculate the time difference between consecutive rows within each "Planta" group
Proud to be a Super User! | |
Hi @leorrn - Please find the attached pbix you can use DAX to calculate the time difference between consecutive rows within each "Planta" group
Proud to be a Super User! | |
@leorrn 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/3395....
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 ) * 1.
Check out the April 2026 Power BI update to learn about new features.
Sign up to receive a private message when registration opens and key events begin.
If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.
| User | Count |
|---|---|
| 38 | |
| 27 | |
| 27 | |
| 22 | |
| 18 |
| User | Count |
|---|---|
| 67 | |
| 36 | |
| 32 | |
| 25 | |
| 25 |