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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
JEM_Systems
Helper I
Helper I

Get the Date difference between values

Hi, how can I get de date difference between documents numbers from the same Name? I'm trying to identify the time the Company Name did the last Sales Order.

Could someone help me?

It Can be on a measure or a calculated column.

Thanks

 

JEM_Systems_1-1696370895339.png

 

 

3 REPLIES 3
Greg_Deckler
Super User
Super User

@JEM_Systems Not sure I quite understand. Can you provide an example of correct output? Seems like everything would be 0 days in your example. This might help:

See my article on Mean Time Between Failure (MTBF) which uses EARLIER: http://community.powerbi.com/t5/Community-Blog/Mean-Time-Between-Failure-MTBF-and-Power-BI/ba-p/3395....
The basic pattern is:
Column = 
  VAR __Current = [Value]
  VAR __PreviousDate = MAXX(FILTER('Table','Table'[Date] < EARLIER('Table'[Date])),[Date])

  VAR __Previous = MAXX(FILTER('Table',[Date]=__PreviousDate),[Value])
RETURN
  __Current - __Previous



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
Power BI Cookbook Third Edition (Color)

DAX is easy, CALCULATE makes DAX hard...

The output should be the number os days of difference. The date on my example is all 10/03/2023 because all of these orders are from today.

I do not understand your example, what VAR __Current = [Value] is? @Greg_Deckler 

@JEM_Systems That just grabs the row's current value of the Value column and stores it in a variable. Subtracting two dates gives back the number of days since a date is just an integer of the number of days since 12/30/1899. If necessary, you can force it to be a number with a RETURN of this:

(__Current - __Previous) * 1.



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
Power BI Cookbook Third Edition (Color)

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.