Forum Discussion

Krlos5411's avatar
Krlos5411
Frequent Visitor
1 year ago
Solved

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 ...
  • gmsamborn's avatar
    1 year ago

    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
        _Result
    

     

     

    Let me know if you have any questions.

     

    Days from Created to Approval.pbix