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

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.

Reply
Jul1An
Frequent Visitor

Calculate date difference between two columns

Hello I have a table in which several incoming documents (from the customer) and several outgoing latters (from the company) are included for customers. I would like to calculate the average time difference between the youngest date of receipt (document receipt) and the oldest date of issue (of the letters) for each customer. Can anyone help here?

Jul1An_0-1671197795502.png

 

5 REPLIES 5
Greg_Deckler
Super User
Super User

@Jul1An No sample data so hard to know exactly what the DAX would be but I answered a very similar question here: YTD Change - Microsoft Power BI Community


@ 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!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

Hey @Greg_Deckler. Thanks for helping. I have added an example to my post

@Jul1An Try:

Measure = 
  VAR __ID = MAX('Table'[Customer-ID]
  VAR __MinDate = MINX(FILTER('Table', [Customer-ID] = __ID), [Date of receipt])
  VAR __MaxDate = MAXX(FILTER('Table', [Customer-ID] = __ID), [Outgoing Date])
  VAR __Result = ( __MaxDate - __MinDate ) * 1.
RETURN
  __Result

@ 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!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

Thanks that helped a lot @Greg_Deckler. One last question on the topic... How must your __Result variable be changed if there is also the case that a letter was sent before an inbox and this constellation should be hidden/ ignored? Can you help here as well?

Jul1An
Frequent Visitor

Hello @Greg_Deckler you have any ideas?

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.