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

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes! Register now.

Reply
rweb95
Frequent Visitor

Date Difference Between Two Most Recent Dates

Hello Power BI community!

 

I need some help trying to find the difference in months between the most recent date entry and the second most recent date entry.

 

I have two measures to find these dates:

1. CalcLatestEffDate = MAX( 'SP-Update Log'[LatestEffectiveDate])
 
2. SecondMostRecentEffDate =
VAR currentdate = [CalcLatestEffDate]
RETURN
CALCULATE(MAX( ('SP-Update Log'[LatestEffectiveDate])), 'SP-Update Log'[LatestEffectiveDate] < currentdate)

 

Both of these measures seem to return the correct dates.

Next I created a calculated column to find the DateDiff:

 

DiffBetweenLastTwoEffDates =
DATEDIFF([SecondMostRecentEffDate], [CalcLatestEffDate], MONTH)
 
This returns nothing but blanks.
 
Any thoughts on how to fix this issue?
1 ACCEPTED SOLUTION
dedelman_clng
Community Champion
Community Champion

Hi @rweb95  - 

 

By using measures to create a column, the context for the column calculation is just the row itself, which is only going to have one date on it.

 

If you want to display the date difference as a "column" in a table or matrix, use the same formula but change the column to a measure and add it to your visualization. This will calculate the value in the correct context.

 

Hope this helps

David

View solution in original post

1 REPLY 1
dedelman_clng
Community Champion
Community Champion

Hi @rweb95  - 

 

By using measures to create a column, the context for the column calculation is just the row itself, which is only going to have one date on it.

 

If you want to display the date difference as a "column" in a table or matrix, use the same formula but change the column to a measure and add it to your visualization. This will calculate the value in the correct context.

 

Hope this helps

David

Helpful resources

Announcements
September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.