Advance your Data & AI career with 50 days of live learning, dataviz contests, hands-on challenges, study groups & certifications and more!
Get registeredGet Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now
Hello,
Hello
How can I calculate the number of hours between the rows in the following table?
Example between the second line and the first should be about 48 hours.
Thank you
Solved! Go to Solution.
Hi @Gianluigi ,
You can create a calculated column as below to get it, please find the details in the attachment.
Column =
VAR _predatetime =
CALCULATE (
MAX ( 'Table'[dataEvento] ),
FILTER (
ALLSELECTED ( 'Table' ),
'Table'[dataEvento] < EARLIER ( 'Table'[dataEvento] )
)
)
RETURN
DATEDIFF ( _predatetime, 'Table'[dataEvento], HOUR )
In addition, you can also create a measure as below to get it.
Number of hours between the rows =
VAR _datetime =
SELECTEDVALUE ( 'Table'[dataEvento] )
VAR _predatetime =
CALCULATE (
MAX ( 'Table'[dataEvento] ),
FILTER ( ALLSELECTED ( 'Table' ), 'Table'[dataEvento] < _datetime )
)
RETURN
DATEDIFF ( _predatetime, _datetime, HOUR )
Best Regards
Hi @Gianluigi ,
You can create a calculated column as below to get it, please find the details in the attachment.
Column =
VAR _predatetime =
CALCULATE (
MAX ( 'Table'[dataEvento] ),
FILTER (
ALLSELECTED ( 'Table' ),
'Table'[dataEvento] < EARLIER ( 'Table'[dataEvento] )
)
)
RETURN
DATEDIFF ( _predatetime, 'Table'[dataEvento], HOUR )
In addition, you can also create a measure as below to get it.
Number of hours between the rows =
VAR _datetime =
SELECTEDVALUE ( 'Table'[dataEvento] )
VAR _predatetime =
CALCULATE (
MAX ( 'Table'[dataEvento] ),
FILTER ( ALLSELECTED ( 'Table' ), 'Table'[dataEvento] < _datetime )
)
RETURN
DATEDIFF ( _predatetime, _datetime, HOUR )
Best Regards
And then this mistake too
Error Message:
The template does not include a table named Column in the eventi table
Hello
FYI, the new column doesn't work. Just save after a few minutes power bi reports this error
Error Message:
There is not enough memory to complete this operation. Please try again later when there may be more memory available.
Great!
Thank you very much!
Hi Gianluigi.
If you update to the latest version of Power BI, you can try out the brand new Visual Calculation feature to calculate row-by-row: Exploring Power BI Visual Calculations – Data – Marc (data-marc.com).
If you use the DATEDIFF() DAX function together with a Visual Calculation, you should be able to achieve what you want.
_____________________________________________________
I hope my comment was helpful.
If your question was answered, please mark your post as 'Solved' and consider giving me a 'Thumbs Up'.
Thank you !
In which visual, Do you want this?
In the table.
Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!
Check out the October 2025 Power BI update to learn about new features.