Forum Discussion
Juju123
2 years agoHelper III
Calculate difference between date group by columns
Hi 🙂 , I have a table in which I want to calculate the days spent between each operation for each Workflow number, article, article designation, operation code and operation label : For ex...
- Anonymous2 years ago
Hi Juju123
You can refer to the following solution.
1.Create a num measure to extract the num from operation code.
No = INT ( MID ( SELECTEDVALUE ( Table1[Operation code] ), SEARCH ( "E", SELECTEDVALUE ( Table1[Operation code] ),, BLANK () ) + 1, LEN ( SELECTEDVALUE ( Table1[Operation code] ) ) - SEARCH ( "E", SELECTEDVALUE ( Table1[Operation code] ),, BLANK () ) ) )2.Create a Rank measure
Rank = RANKX ( FILTER ( ALLSELECTED ( Table1 ), [Workflow number] IN VALUES ( Table1[Workflow number] ) && [Article] IN VALUES ( Table1[Article] ) ), [No], , ASC )3.Then calculate the differnce
Temps entre chaque operation = VAR a = [Rank] - 1 VAR _predate = MAXX ( FILTER ( ALLSELECTED ( Table1 ), [Workflow number] IN VALUES ( Table1[Workflow number] ) && [Article] IN VALUES ( Table1[Article] ) && [Rank] = a ), [Operation Date] ) RETURN IF ( DATEDIFF ( _predate, MAX ( Table1[Operation Date] ), DAY ) <> BLANK (), DATEDIFF ( _predate, MAX ( Table1[Operation Date] ), DAY ), 0 )Output
Best Regards!
Yolo Zhu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Juju123
2 years agoHelper III
I added a column which is the operation number.
I modified this formula to retrieve the previous date for each Workflow/Article pair:
Previous_Date = MAXX(FILTER(ALL('CAGC_ADVL_INDICATEURS_ETAPES_WF_REP'),CAGC_ADVL_INDICATEURS_ETAPES_WF_REP[Numero de l'operation]<SELECTEDVALUE('CAGC_ADVL_INDICATEURS_ETAPES_WF_REP'[Numero de l'operation])&&[Designation article]=SELECTEDVALUE('CAGC_ADVL_INDICATEURS_ETAPES_WF_REP'[Designation article])),CAGC_ADVL_INDICATEURS_ETAPES_WF_REP[WF - Date fin reelle])
I can recover the previous date but not always.
How can I fix this problem
Merci
ryan_mayu
2 years agoSuper User
pls see the attachment below