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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
Dyke211
Helper I
Helper I

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
Helper I
Helper I

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...

Anonymous
Not 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.

Helpful resources

Announcements
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.