Forum Discussion
Calculate the difference between each date
- 2 years ago
Hi, Juju123
This result you expect still requires the addition of the index column. But considering that you are in direct query mode, you can't add it in Power query kind of thing. is the operation code in sequential order?
Measure:
Code index = VALUE(RIGHT(SELECTEDVALUE('Table'[Operation code]),3))Previous code index = VAR _index = [Code index] RETURN MAXX ( FILTER ( ALL ( 'Table' ), [Code index] < _index && [Article] = SELECTEDVALUE ( 'Table'[Article] ) && [Workflow] = SELECTEDVALUE ( 'Table'[Workflow] ) && [Designation article] = SELECTEDVALUE ( 'Table'[Designation article] ) ), [Code index] )Previous date = Var _preindex=[Previous code index] Return MAXX(FILTER(ALL('Table'),[Code index]=_preindex && [Article] = SELECTEDVALUE ( 'Table'[Article] ) && [Workflow] = SELECTEDVALUE ( 'Table'[Workflow] ) && [Designation article] = SELECTEDVALUE ( 'Table'[Designation article] ) ),[Operation date])Is this the result you expect?
Best Regards,
Community Support Team _Charlotte
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi Greg_Deckler ,
thanks for your answer.
i read your post about MBT and I take your code.
i would like understand , what does [value] correspond to ?
i modify the code like this :
Time each operation =
VAR _Current = [Value] ?
VAR _PreviousDate = MAXX(FILTER('T1','Table'[Operation date] < EARLIER('T1'[Operation date])),[Operation date])
VAR _Previous = MAXX(FILTER('T1',[Operation date]= VAR _PreviousDate),[Value])
RETURN
VAR _Current - VAR _Previous
thanks you