Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
3 years ago

Time between two dates based on criteria

Hello! 

I have a table of ticket data where I for each critical ticket need to calculate the time since the last critical ticket was registered.
Been trying to solve this for a few hours now without success.

Basically: If Priority = Critical, calculate time between regdate and previous critical tickets' regdate (for each row). The goal is to calculate the average time between critical tickets being registered.

 

Any help would be greatly apreciated! 

5 Replies

  • Hi Jowh, 

    Not sure about your use case, is it something like below:

    here comes the code for the calculated column:
    Duration =
    VAR CurrentDate = 'Table'[Date]
    VAR TABLE1 =
        CALCULATETABLE(
            'TABLE',
            FILTER ('Table', 'Table'[Priority]="Yes"),
            FILTER ('Table', 'Table'[Date]>CurrentDate)
        )
    VAR MinDate =
        MINX (
             TABLE1,
            'Table'[Date]-CurrentDate)
    RETURN
        IF (
            'Table'[Priority]="Yes",
            INT( MinDate)
        )
    • Anonymous's avatar
      Anonymous
      Not applicable

      Hello and thank you! 

      It is something similar but in the reverse order I suppose. Latest date should show the previous max date with Priority if that makes sense. Also presented in hours or minutes but I think I could figure that part out myself in worst case 🙂