Forum Discussion
Compare two dates in different lines for same ID
Hi All,
I need to calculate the time between the CREATE status and the APPROVAL status for every ticket that has those stages.
There's some tickets that has no APPROVAL status for example. So I need to check first if the ticket has the APPROVAL status and then, calculate the time between the two stages.
Thanks for your help!
Hi Krlos5411
Would a measure like this work?
Days from Created to Approval = VAR _CurrStatus = SELECTEDVALUE('Table'[Status]) VAR _Create = CALCULATE( MIN('Table'[Due Date]), ALL('Table'[Due Date]), 'Table'[Status] = "CREATE" ) VAR _Approval = CALCULATE( MAX('Table'[Due Date]), ALL('Table'[Due Date]), 'Table'[Status] = "APPROVAL" ) VAR _Result = IF( NOT ISBLANK(_Approval) && _CurrStatus = "APPROVAL", DATEDIFF(_Create, _Approval, DAY) ) RETURN _ResultLet me know if you have any questions.
Days from Created to Approval.pbix
12 Replies
- gmsambornSuper User
Hi Krlos5411
Would a measure like this work?
Days from Created to Approval = VAR _CurrStatus = SELECTEDVALUE('Table'[Status]) VAR _Create = CALCULATE( MIN('Table'[Due Date]), ALL('Table'[Due Date]), 'Table'[Status] = "CREATE" ) VAR _Approval = CALCULATE( MAX('Table'[Due Date]), ALL('Table'[Due Date]), 'Table'[Status] = "APPROVAL" ) VAR _Result = IF( NOT ISBLANK(_Approval) && _CurrStatus = "APPROVAL", DATEDIFF(_Create, _Approval, DAY) ) RETURN _ResultLet me know if you have any questions.
Days from Created to Approval.pbix
- gmsambornSuper User
After looking at your pbix again, I realized the measure I added already exists as [AVG days].
In your visuals you should use the [AVG days] measure since it handles the rows as well as the average.
I tried that measure and it works as far as I can tell.
Are your sure the 2.43 measure ( [AVG Expected Result] ) is correct?