Forum Discussion
Dyke211
Helper I
2 years agoCalulcuating Date difference in days within same column
Hello Guys, i want to get the number of days between the dates within same column in DAX. FOR INSTANCE.. wOULD LIKE TO REPLICATE THIS IN POWER bi
quantumudit
Super User
2 years agoHi Dyke211
You can use the following DAX formula to create the calculated column in the table:
Days =
VAR _currentDate = Assets[Date]
VAR _previousDate =
CALCULATE (
LASTDATE ( Assets[Date] ),
FILTER ( Assets, Assets[Date] < _currentDate )
)
VAR _days =
DATEDIFF ( _previousDate, _currentDate, DAY )
RETURN
IF ( ISBLANK ( _days ), 0, _days )
Here is the snapshot of the solution:
Best Regards,
Udit
If this post helps, then please consider Accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudo 👍
🚀 Let's Connect: LinkedIn || YouTube || Medium || GitHub
✨ Visit My Linktree: LinkTree
- Dyke2112 years ago
Helper I
Hi, I just tried your code with the actual data, but got this errorHow this column looks likeThe error i got...
- Anonymous2 years agoNot applicable
As the error states, it looks like your [EVT_OBJECT] column is not of DATE data type, this will need transforming before the measure will work.