Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
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.
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
106 | |
105 | |
79 | |
69 | |
62 |
User | Count |
---|---|
143 | |
104 | |
103 | |
82 | |
70 |