Forum Discussion
findout date difference between two dates and non dates
MahamoodBi First part is easy, it is
Measure =
( MAX([TermDate]) - MAX([ServiceDate]) ) * 1.
2nd part:
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/339586.
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
Greg_Deckler i need both dax function in single caluclated column ,could you please suggest
- Greg_Deckler3 years ago
Community Champion
MahamoodBi Right, that's a simple
IF( MAX('Table'[ServiceDate]) <> BLANK(),
( MAX([TermDate]) - MAX([ServiceDate]) ) * 1.,
... //second measure goes here
)
- MahamoodBi3 years agoFrequent Visitor
Greg_Deckler i need to divided by 12,because i am finding date difference between two dates by month
second point coding i didnĂ˝ understood could you please cexplain
- Greg_Deckler3 years ago
Community Champion
MahamoodBi I can't provide you with a specific solution without sample data to build a model out and code it. Sorry, having trouble following, can you post sample data as text and expected output?
Not really enough information to go on, please first check if your issue is a common issue listed here: https://community.powerbi.com/t5/Community-Blog/Before-You-Post-Read-This/ba-p/1116882
Also, please see this post regarding How to Get Your Question Answered Quickly: https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490
The most important parts are:
1. Sample data as text, use the table tool in the editing bar
2. Expected output from sample data
3. Explanation in words of how to get from 1. to 2.