Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
Dyke211
Frequent Visitor

Calulcuating 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 biwHAT I WANTwHAT I WANTwHAT I HAVEwHAT I HAVE

5 REPLIES 5
Dyke211
Frequent Visitor

tHE oBJECT ISNT MEANT TO BE A DATE ITS ACTUALLY UNIQUE VALUES OF THINGS

quantumudit
Continued Contributor
Continued Contributor

Hi @Dyke211 

Please correct me if I have misunderstood the issue. However, you need a date field to calculate the "days" difference between subsequent rows. If you wish to retain it as a text field, then you must convert it into a date type during the calculation to determine the days difference.

If that is the case, then simply use DATEVALUE(Assets[Date]) instead.

quantumudit
Continued Contributor
Continued Contributor

Hi @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:

quantumudit_0-1713896526221.png

 

 

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

Hi, I just tried your code with the actual data, but got this errorHow this column looks likeHow this column looks likeThe error i got...The error i got...

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.

Helpful resources

Announcements
PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

Top Solution Authors