Forum Discussion
Measure to filter days between operations
- 7 years ago
Hi Tommyvhod ,
Try these two measures to get the result in the picture. My table name is Fin.
Let me know if you have any questions.
If this solves your issues, please mark it as the solution, so that others can find it easily. Kudos are nice too.
NathanielDate diff = VAR _Time = ( Fin[Finish date] ) //captures current date Var _maxLastTime = CALCULATE(MAX(Fin[Finish date]),FILTER(ALLEXCEPT(Fin,Fin[ID ]),Fin[Finish date]< _Time)) var _datedif =DATEDIFF(_maxLastTime,Fin[Finish date],day) return if(_datedif>0,_datedif,0) ================== Date Dif per ID = CALCULATE(DATEDIFF(MIN(Fin[Finish date]),MAX(Fin[Finish date]),DAY),Filter(ALLEXCEPT(fin,Fin[ID ]),Fin[ID ])
Hi Tommyvhod ,
Try these two measures to get the result in the picture. My table name is Fin.
Let me know if you have any questions.
If this solves your issues, please mark it as the solution, so that others can find it easily. Kudos are nice too.
Nathaniel
Date diff =
VAR _Time =
( Fin[Finish date] ) //captures current date
Var _maxLastTime = CALCULATE(MAX(Fin[Finish date]),FILTER(ALLEXCEPT(Fin,Fin[ID ]),Fin[Finish date]< _Time))
var _datedif =DATEDIFF(_maxLastTime,Fin[Finish date],day)
return
if(_datedif>0,_datedif,0)
==================
Date Dif per ID = CALCULATE(DATEDIFF(MIN(Fin[Finish date]),MAX(Fin[Finish date]),DAY),Filter(ALLEXCEPT(fin,Fin[ID ]),Fin[ID ])
- Tommyvhod7 years ago
Helper II
Nathaniel_C Thank you for your answer. I was unable to add the first measure. I wanted to add as a new measure where the data is, but I was unable to write the VAR expression. Did I want to add the measure in the wrong place?
For the second measure I received the following error message:
A single value for column 'ID' in table 'QAD_Data' cannot be determined. This can happen when a measure formula refers to a column that contains many values without specifying an aggregation such as min, max, count, or sum to get a single result.
- Nathaniel_C7 years ago
Community Champion
Hi Tommyvhod ,
So you provided us with a table. I just added a calculated column to the table.
Is that what you are doing? Let's work with DateDiff first.
You should be able to copy and paste, and then change the names to your table.
- Nathaniel_C7 years ago
Community Champion
Hi Tommyvhod ,
Or as measures: Date diff m = VAR _Time = MAX ( Fin[Finish date] ) //captures current date VAR _maxLastTime = CALCULATE ( MAX ( Fin[Finish date] ), FILTER ( ALLEXCEPT ( Fin, Fin[ID ] ), Fin[Finish date] < _Time ) ) VAR _datedif = DATEDIFF ( _maxLastTime, _Time, DAY ) RETURN IF ( _datedif > 0, _datedif, 0 ) ========================================== Date Dif per ID m = CALCULATE ( DATEDIFF ( MIN ( Fin[Finish date] ), MAX ( Fin[Finish date] ), DAY ), FILTER ( ALLEXCEPT ( fin, Fin[ID ] ), MAX ( Fin[ID ] ) ) )